您的位置:首页 > 其它

怎样判断复选框是否被选中

2015-12-27 18:14 351 查看



网上搜索很多资料,亲测以下方法有效:


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script type="text/javascript">
$(function(){
$("button").click(function() {
$(".checkbox").each(function() {
alert($(this).is(":checked"))
});

});
})

</script>
</head>
<body>
<input type="checkbox" class="checkbox" id="checkbox_id1" value="1" />1
<input type="checkbox" class="checkbox" id="checkbox_id2" value="2" />2
<input type="checkbox" class="checkbox" id="checkbox_id3" value="3" />3
<input type="checkbox" class="checkbox" id="checkbox_id4" value="4" />4
<input type="checkbox" class="checkbox" id="checkbox_id5" value="5" />5
<button>提交</button>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: