前端获取 checkbox 所有选中状态的值

获取 checkbox 所有选中状态的值

html代码

<input type="checkbox" obj_id="1" class="c-box">
<input type="checkbox" obj_id="2" class="c-box">
<input type="checkbox" obj_id="3" class="c-box">
<input type="checkbox" obj_id="4" class="c-box">

js代码

$(".c-box:checked").each(function(){
     alert($(this).attr("obj_id"));//遍历选中项的值
});

亲自测试, 有效!


版权声明:本文为Monkey_yang_zb原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。