jQuery Checkbox 全选 反选的简单实例

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://xiazai.jb51.net/201611/yuanma/jquery(jb51.net).rar"></script> <script type="text/javascript"> $(function () { $("#selall").on("click", function () { $("#plalst :checkbox").prop("checked", true); }); $("#selnone").on("click", function () { $("#plalst :checkbox").prop("checked", false); }); $("#resver").on("click", function () { $("#plalst :checkbox").prop("checked", function (i, val) { return !val; }); }); $("#chkAll").on("click", function () { $("#plalst :checkbox").prop("checked", $("#chkAll").prop("checked")) }); }); </script> </head> <body> <div> <input type="checkbox" />一队 <input type="checkbox" />二队 <input type="checkbox" />三队 <input type="checkbox" />四队 <input type="checkbox" />五队 <input type="checkbox" />六队 </div> <br /><br /><br /> <input type="button" value="全选" /> <input type="button" value="全不选" /> <input type="button" value="反选" /> <input type="checkbox" /><label for="chkAll" >选择</label> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwxdxp.html