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

checkbox:获取选中的checkbox

时间:2015-06-27 16:03:00      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:

4,有多个checkbox,选出第一个选中的checkbox:

 
    $("#btn").click(function () {            
        //选择checkbox前面加冒号,选中属性前加冒号
        var checks = $("#table2 :checkbox:checked");
        if (checks.length > 0) {  
        //eq是第几个,从0开始                
            var sid = checks.eq(0).parent().parent().attr("id");
            alert(sid);
        }
        else {
            alert("你没有选择");
        }
    });
技术分享

页面结构:

 
    <input type="button" id="btn" value="单击" />
    <table id="table2">
    <tr guid="ed2d15679cce4100b7ad4a4f27bf8f02" num="11" id="108580">
    <td style="width: 20px; color: rgb(0, 0, 0);"><input type="checkbox" value="108580" name="id"></td>
    </tr>
    </table>

checkbox:获取选中的checkbox

标签:

原文地址:http://www.cnblogs.com/wyBlog117/p/4604004.html

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