码迷,mamicode.com
首页 > 其他好文 > 详细

单选框的选中事件

时间:2018-05-22 12:36:29      阅读:482      评论:0      收藏:0      [点我收藏+]

标签:col   div   默认   title   min   put   har   inpu   cti   

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <label>第一个</label>
        <input name="radio1" type="radio" id="input1">
        <label>第二个</label>
        <input name="radio1" type="radio" id="input2">
    </body>
    <script src="js/jquery.min.js"></script>
    <script>
        $("#input1").attr("checked","checked");//默认第一个选中
        $(input:radio[name="radio1"]).change(function () {
            if($("#input1").is(":checked")){
                alert("选中第一个!")
            }
            if($("#input2").is(":checked")){
                alert("选中第二个!")
            }
        })
    </script>
</html>

 

单选框的选中事件

标签:col   div   默认   title   min   put   har   inpu   cti   

原文地址:https://www.cnblogs.com/weilingfamily/p/9070995.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!