zoukankan      html  css  js  c++  java
  • JavaScript练习

    正反选练习

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    
        <div>
            <input type="button" value="全选" onclick="f1()">
            <input type="button" value="反选" onclick="f2()">
            <input type="button" value="取消" onclick="f3()">
    
    
            <ul>
                <li><input type="checkbox">aaaaa</li>
                <li><input type="checkbox">aaaaa</li>
                <li><input type="checkbox">aaaaa</li>
                <li><input type="checkbox">aaaaa</li>
                <li><input type="checkbox">aaaaa</li>
                <li><input type="checkbox">aaaaa</li>
            </ul>
        </div>
    
        <script src="jquery-1.12.4.min.js"></script>
        <script>
            // function f1(){
            //     $(':checkbox').each(function () {
            //         $(this).prop('checked',true)
            //     })
            // }
            function f1(){
                $(':checkbox').prop('checked',true);
            }
            function f2(){
                $(':checkbox').each(function () {
                    if ($(this).prop('checked')){
                        $(this).prop('checked',false)
                    }
                    else {
                        $(this).prop('checked',true)
                    }
                })
            }
            function f3(){
                $(':checkbox').removeProp("checked");
            }
        </script>
    </body>
    </html>
  • 相关阅读:
    js的基本数据类型有哪些?
    UML 类图
    三种代理模式
    jsp 知识点
    httpServlet
    Qt时间&日期
    Microsoft visual studio C 运行时库 在 xx.exe中检测到一个错误
    C++调用COM之错
    PCL中的bug修改
    Qt使用SQLite
  • 原文地址:https://www.cnblogs.com/Anec/p/9857747.html
Copyright © 2011-2022 走看看