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>
    
  • 相关阅读:
    别人走的路-1
    抽象类跟接口的区别
    一个类实现多个接口的demo
    servlet+jdbc+javabean其实跟ssh差不多
    什么是shell
    设置cookie倒计时让让表单自动提交
    变量、基本数据类型
    编程语言、添加环境变量、变量
    Java优先队列一些问题
    JavaScript学习-JSON
  • 原文地址:https://www.cnblogs.com/gerenboke/p/11772184.html
Copyright © 2011-2022 走看看