1 回答
TA贡献1790条经验 获得超9个赞
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<input type="checkbox" name="test" value="123">123
<br/>
<input type="checkbox" name="test" value="456">456
<br/>
<input type="checkbox" name="test" value="789">789
<br/>
<input type="checkbox" name="test" value="563">563
<br/>
<input type="checkbox" name="test" value="156">156
<br/>
<input type="checkbox" name="test" value="110">110
<br/>
<div style="width:290px; height:50px; border:1px solid;">
</div>
<script src="jquery.min.js"></script>
<script type="text/javascript">
//改这些复选框统一的name属性,比如name="test",加上对应的value值
$('input[name=test]').change(function() {
var arr = []
$('input[name=test]:checked').each(function(i, v) {
arr.push($(v).val())
})
$('div').html(arr.join(','))
})
</script>
</body>
</html>
添加回答
举报