Changing CheckBox states in facebox using jQuery / AJAX
I am using jQuery AJAX to dynamically lo开发者_开发百科ad web user control's HTML via web service into one of my <div>
element.
The problem arises when I use facebox
plugin to show that div
as a popup. I have Select All / None checkboxes in this div
which should select all checkboxes or deselect all of them.
Without an example of your code, it's a little difficult to really understand what you want, but I'll make a guess. Here's one way to make a "select all" checkbox:
HTML:
<input type="checkbox" class="select-all" name="select-all" id="select-all" value="select all" />
<label for="select-all">Select All</label>
<input type="checkbox" class="checkbox" name="checkbox1" id="checkbox1" value="1"/>
<input type="checkbox" class="checkbox" name="checkbox2" id="checkbox2" value="2"/>
<input type="checkbox" class="checkbox" name="checkbox3" id="checkbox3" value="3"/>
<input type="checkbox" class="checkbox" name="checkbox4" id="checkbox4" value="4"/>
<input type="checkbox" class="checkbox" name="checkbox5" id="checkbox5" value="5"/>
jQuery:
$("#select-all").click(function(){
if ($(this).attr("checked") == "checked") {
$(".checkbox").attr("checked", "checked");
} else {
$(".checkbox").removeAttr("checked");
}
});
精彩评论