jQuery常用属性过滤选择器

常用属性过滤选择器

用户名:
密 码:
性 别:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
        <title>常用属性过滤选择器</title>
    <script src="scripts/jquery-3.1.1.js" type="text/javascript"></script>
    <script type="text/javascript">
            $(function(){
                //选取所有包含type的元素的长度
               // alert($("[type]").length);
                //查找form下的并且包含type属性的所有元素
                //alert($("form *[type]").length);
                //alert($("[value^='提交']").length);//2  以...开始
                //alert($("[value$='表单']").length);//3  以...结尾
               // alert($("[value*='提']").length);    //3  包含...的
               // alert($("input[name=sex]").length);
               // alert($("input[name!=sex]").length);
                //[] []多个属性的判断
                alert($("input[class=c1] [type=text]").length);
            });

    </script>
</head>
<body>
<form id="form" action="#" method="post">
    用户名:<input id="name" class="c1" type="text" name="name"><br/>
    密 码:<input id="password" class="c1" type="password" name="name"><br/>
    性 别:<input name="sex" type="radio" value="male" checked>男
    <input name="sex" type="radio" value="female">女<br/>
    <input type="submit" value="提交表单">
    <input type="submit" value="提交 表单">
    <input type="submit" value="提 交 表单">
    <input type="reset" value="重置"><br/>
    <button type="submit">提交</button>
    <button type="reset">重置</button>
</form>
</body>
</html>

  

posted @ 2017-02-20 19:09  john。  阅读(1581)  评论(0编辑  收藏  举报