$('#checkedAll').click(function(){
    if ($(this).attr('checked')==true)
    {
       $('#div input[type=checkbox]').each(function(){
       $(this).attr('checked',true);
       });
    }
    else
    {
       $('#div input[type=checkbox]').each(function(){
       $(this).attr('checked',false);
       });
    }
    
    });
       <div id="div">
        <input type="checkbox" id="checkedAll" />全选<br/>
        <input type="checkbox" value="1" /><br/>
        <input type="checkbox" value="2" /><br/>
        <input type="checkbox" value="3" /><br/>
        <input type="checkbox" value="4" /><br/>
        <input type="checkbox" value="5" /><br/>
        <input type="checkbox" value="6" /><br/>
       </div>

 

posted on 2014-04-13 23:20  苏荷酒吧  阅读(109)  评论(0)    收藏  举报