JQuery based on the implementation of the checkbox of all not selected anti selection function


This code is selected in the numerous jQuery checkbox function code, the code used in my project, here to share with you.

JQuery code:

        $(function(){
            $("#checkedAll").click(function(){
                $('[name=items]:checkbox').attr('checked',true);
            });
            $("#checkedNo").click(function(){
                $('[name=items]:checkbox').attr('checked',false);
            });
            $("#checkedRev").click(function(){
                $('[name=items]:checkbox').each(function(){
                    //$(this).attr('checked',!$(this).attr('checked'));
                    this.checked = !this.checked;
                });
            });
            $("#send").click(function(){
               var str = " What you selected is: rn";
               $('[name=items]:checkbox:checked').each(function(){
                   str += $(this).val()+"rn";
               });
                alert(str);
            });
        }); 

HTML code:

     What's your favorite sport? <br>
    <input type="checkbox" name="items" value=" football "/> football
    <input type="checkbox" name="items" value=" basketball "/> basketball
    <input type="checkbox" name="items" value=" badminton "/> badminton
    <input type="checkbox" name="items" value=" Table tennis "/> Table tennis <br>
    <input type="button" id="checkedAll" value=" all   choose "/>
    <input type="button" id="checkedNo" value=" All don't choose "/>
    <input type="button" id="checkedRev" value=" the   choose "/>
    <input type="button" id="send" value=" mention   Hand in "/>