1. 程式人生 > >jQuery js實現checkbox復選框全選、全不選、反選 PHP

jQuery js實現checkbox復選框全選、全不選、反選 PHP

實現 com check set false jquer display value round

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全選、全不選、反選</title>
    <style type="text/css">
        #choose input {
            display: block;
        }
    </style>
    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"
></script> <script type="text/javascript"> $(function(){ var $choose = $("#choose input"); //全選 $("#all").click(function(){ $choose.each(function(){ $(this).prop("checked",true); }); });
//全不選 $("#not").click(function(){ $choose.prop("checked",false); }); //反選 $("#reverse").click(function(){ $choose.each(function(){ $(this).prop("checked",!$(this).prop("checked")); }); }); });
</script> </head> <body> <div id="box-function"> <input id="all" type="button" value="全選" /> <input id="not" type="button" value="全不選" /> <input id="reverse" type="button" value="反選" /> </div> <div id="choose"> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> <input type="checkbox" /> </div> </body> </html>

jQuery js實現checkbox復選框全選、全不選、反選 PHP