jQuery实现全选与全不选

前端之家收集整理的这篇文章主要介绍了jQuery实现全选与全不选前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

【前言】

     jQuery实现全选与全不选

 

【主体】

     之前文章用JS实现全选纯JS实现全选与全不选,这里介绍下如何通过jquery实现全选。

全选:<input type="checkBox" name="delAll" onchange="checkAll()">  
<input type="checkBox" name="del">  
<input type="checkBox" name="del">  
<input type="checkBox" name="del">  
<input type="checkBox" name="del">  
<input type="checkBox" name="del"> 
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(function(){
   $("input[name=delAll]").click(function(event) {
      $("input[name=del").attr("checked",$(this[0].checked);
   });
})
</script>

 

猜你在找的jQuery相关文章