jQuery Checkbox 全選 反選的簡單實例
更新時間:2016年11月29日 08:34:56 作者:森林王子
本文主要介紹了Checkbox的全選、反選的簡單實例,需要的朋友可以參考下
1.全選、反選
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="http://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 id="plalst"> <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" id="selall" value="全選" /> <input type="button" id="selnone" value="全不選" /> <input type="button" id="resver" value="反選" /> <input type="checkbox" id="chkAll" /><label for="chkAll" >選擇</label> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家有所幫助,同時也希望多多支持腳本之家!
相關(guān)文章
jQuery+Ajax請求本地數(shù)據(jù)加載商品列表頁并跳轉(zhuǎn)詳情頁的實現(xiàn)方法
本文通過實例代碼給大家介紹了jQuery+Ajax請求本地數(shù)據(jù)加載商品列表頁并跳轉(zhuǎn)詳情頁,需要的朋友可以參考下2017-07-07jQuery使用模式窗口實現(xiàn)在主頁面和子頁面中互相傳值的方法
這篇文章主要介紹了jQuery使用模式窗口實現(xiàn)在主頁面和子頁面中互相傳值的方法,涉及jQuery模式窗口及參數(shù)傳遞相關(guān)技巧,需要的朋友可以參考下2016-03-03