zoukankan      html  css  js  c++  java
  • 指定查询范围

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <script src="Scripts/jquery-1.8.2.min.js"></script>
        <script type ="text/javascript">
            $(function () {
                $("#btn1").click(function () {
                    //获取页面第一个表单
                    var form = $("form:first");
    
                    //指定选择器的查询上下文为form
                    //如果没有为选择器指定上下文(只传一个参数)jq会到dom树里面查找
                    //如果加了上下文(传递了两个参数),那么jq就到第二个参数里查找
                    var checkedBox = $("input[name=chkl]:checked", form); //到指定的上下文里查找
                    alert(checkedBox.length);
                });
               
            });
        </script>
    </head>
    <body>
        <form action="" method ="post">
           用户名:
            <input type ="text" />
            密码:
            <input type ="password" />
            <input type ="checkbox" name="chkl" />
             <input type ="checkbox" name="chkl" />
             <input type ="checkbox" name="chkl" />
        </form>
        <input type ="button" id="btn1" value="点击"/>
    </body>
    </html>
    

      

  • 相关阅读:
    算法
    autoreleasepool和weak
    记录一下锁如何使用
    RunLoop相关知识
    NSTimer内存泄漏的解决方案
    ARC下block循环引用的解决方式
    MGJRouter源码解析及使用方法
    Instruments 中Time Profile的使用
    NSFileManager的基本使用
    Runtime相关知识
  • 原文地址:https://www.cnblogs.com/sumg/p/3787718.html
Copyright © 2011-2022 走看看