我对 jquery 复选框感到困惑 :checked 选择器。即使在阅读文档之后,我也不知道如何使用它。
HTML:
<div class="addbox">
<h4><span class="addbox-text">Pick your best work from <b class="highlight-text">Flickr</b> to display in your portfolio</span></h4>
<div class="addbox-buttons"><input type="button" id="addbox-add" value="Add"><input type="button" id="addbox-cancel" value="Cancel"></div>
<div class="addmenu-item" id="addmenu-item-1e30"><span class="addmenu-image"><img class="addmenuimage" src="http://farm8.staticflickr.com/7122/7424355198_72620895bd_m.jpg"></span><span class="addmenu-info"><input type="checkbox" id="add-check-1e30">Orchid Profiles</span></div>
<div class="addmenu-item" id="addmenu-item-1230"><span class="addmenu-image"><img class="addmenuimage" src="http://farm8.staticflickr.com/7122/7424355198_72620895bd_m.jpg"></span><span class="addmenu-info"><input type="checkbox" id="add-check-1230">Orchid Profiles</span></div>
</div>
用于检查的 jQuery:
$("#addbox-add").click(function(){
$("input[type=checkbox] :checked").each( function() {
alert("yes");
});
});
如果单击添加按钮,则有两个复选框,它将显示每个选中复选框的警报消息。但它不起作用。谁能指出错误?