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>
    

      

  • 相关阅读:
    第七周学习进度
    环形数组求子数组最大和
    第六周学习进度
    团队
    子数组和最大值
    第五周学习进度
    第四周学习进度
    构建之法第一篇阅读笔记
    关于Sublime text 的PHP编译环境配置的问题
    PHP基础之 数组(二)
  • 原文地址:https://www.cnblogs.com/sumg/p/3787718.html
Copyright © 2011-2022 走看看