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>
    
  • 相关阅读:
    一个简单的php站点配置
    nginx基本配置
    redis命令大全
    while()
    遍历字符串
    带空格的字符串逆转(简洁版)
    Java Swing 介绍
    java键盘输入
    做一个完整的Java Web项目需要掌握的技能
    biu
  • 原文地址:https://www.cnblogs.com/gerenboke/p/11772184.html
Copyright © 2011-2022 走看看