标签:span rop style click lse rev bsp ble doctype
JQuery
实例:
多选/复选
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="JQuery-1.12.4.js"></script> </head> <body> <input type="button" value="all" onclick="chooseAll()"> <input type="button" value="noAll" onclick="chooseNo()"> <input type="button" value="reverseAll" onclick="reverseAll()"> <table border="1"> <thead> <tr> <th>checked</th> <th>ip</th> <th>port</th> </tr> </thead> <tbody> <tr> <td><input type="checkbox"> </td> <td>2.2.2.2</td> <td>32</td> </tr> <tr> <td><input type="checkbox"> </td> <td>2.3.3.3</td> <td>33</td> </tr> <tr> <td><input type="checkbox"> </td> <td>2.4.4.4</td> <td>34</td> </tr> </tbody> </table> </body> </html> <script> function chooseAll(){ $(‘:checkbox‘).prop(‘checked‘, true); } function chooseNo(){ $(‘:checkbox‘).prop(‘checked‘, false); } function reverseAll(){ $(‘:checkbox‘).each(function(k){ //this:当前循环的每一个元素 //k key-index, console.log(k, this) if(this.checked){ this.checked = false } else{ this.checked = true } }) } </script>
标签:span rop style click lse rev bsp ble doctype
原文地址:https://www.cnblogs.com/hinimix/p/9284601.html