我的代码出了什么问题,我没有得到任何价值:
<script>
$(document).ready(function()
{
$("input[type=checkbox][checked]").each(function(event){
var get = $("input[@name=\'checkbox_pref\']:checked").val();
$("#result").html("&id=" + get);
});
});
</script>
</head>
<body>
<input type="checkbox" name="checkbox_pref" value = "1"/>
<input type="checkbox" name="checkbox_pref" value = "2"/>
<input type="checkbox" name="checkbox_pref" value = "3"/>
<div id="result">result ...</div>
Run Code Online (Sandbox Code Playgroud)
取决于你想要做什么,但它应该更符合以下方面:
$(document).ready(function()
{
$("input[type=checkbox]").change(function(event){
$("#result").html("&id=" + this.value);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
365 次 |
| 最近记录: |