zoukankan      html  css  js  c++  java
  • jQuery属性操作

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.1.1.js"></script>
    </head>
    <body><button onclick="selectall();">全选</button>
    <button onclick="cancel();">取消</button>
    <button onclick="reverse();">反选</button>
    <table border="1">
    <tr>
    <td><input type="checkbox"></td>
    <td>111</td>
    </tr>
    <tr>
    <td><input type="checkbox"></td>
    <td>222</td>
    </tr>
    <tr>
    <td><input type="checkbox"></td>
    <td>333</td>
    </tr>
    <tr>
    <td><input type="checkbox"></td>
    <td>444</td>
    </tr>
    </table>
    <script>
    ​
    ​
    //li=[10,20,30,40]
    //dic={name:"yuan",sex:"male"}
    //$.each(dic,function(i,x){
    // console.log(i,x)
    // })
    ​
    ​
    // $("table tr").each(function () {
    // console.log($(this).html())
    // })
    ​
    ​
    function selectall() {
    $("table :checkbox").each(function () {
    $(this).prop("checked",true)
    })
    }
    ​
    function cancel() {
    $("table :checkbox").each(function () {
    $(this).prop("checked",false);
    })
    }
    ​
    function reverse() {
    $("table :checkbox").each(function () {
    if($(this).prop("checked")){
    $(this).prop("checked",false);
    }
    else {
    $(this).prop("checked",true);
    }
    ​
    })
    }
    ​
    ​
    </script>
    </body>
    </html>
    
  • 相关阅读:
    android中添加只有border-left的样式
    TreeSet, LinkedHashSet and HashSet 的区别
    android添加桌面悬浮窗
    Android 桌面小部件
    专辑一:爱之初体验(中级)
    电影 — 百度云资源搜索网站
    托福单词-第三天
    程序代码英语积累
    托福单词-第二天
    托福单词-第一天
  • 原文地址:https://www.cnblogs.com/gerenboke/p/11772184.html
Copyright © 2011-2022 走看看