jquery的全选、全不选、反选例子

<li><span><input type="checkbox" name="checkbox1" class="checkbox" value="checkbox" onfocus="this.blur()" ></span>北京西城区</li>
<li><span><input type="checkbox" name="checkbox1" class="checkbox" value="checkbox" onfocus="this.blur()" ></span>北京崇文区</li>
<li><span><input type="checkbox" name="checkbox1" class="checkbox" value="checkbox" onfocus="this.blur()" ></span>北京宣武区</li>


<input type="button" name="btnCheckedAll" value="全 选" onclick="javascript:$(':checkbox[name=checkbox1]').attr('checked','checked');" />
<input type="button" name="btnCheckedNo" value="全不选" onclick="javascript:$(':checkbox[name=checkbox1]').attr('checked','')" />
<input type="button" name="btnCheckedRev" value="反 选" onclick="javascript:$(':checkbox[name=checkbox1]').each(function(){ $(this).attr('checked', !($(this).attr('checked')));}) ;" />

你可能感兴趣的:(jquery)