保存多个复选框的内容
程序员文章站
2024-01-02 12:50:46
...
<html>
<head>
<script src='./jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$("#submitButton").click(function(){
var checked = [];
$('input:checkbox:checked').each(function() {
checked.push($(this).val());
});
alert(checked);
});
});
</script>
</head>
<body>
<input type='checkbox' id='sendMessage' name='message' value='1'>发送短信</input>
<input type='checkbox' id='sendMessage' name='message' value='2'>发送邮件</input>
<input type='button' class = 'submit' id='submitButton' value='提交'/>
</body>
</html>