jquery的过滤学习

$("p").eq(1)  匹配下标为1的p标签     
 
$("p").hasClass("a")匹配所有p标签class中包含a的  ,如果有,则返回true
 
$("div").filter(".c") 匹配所有div中包含c的class,可以是任意属性值选择器,且可以是多个例:$("div").filter(".c",".d")
 
$("div").filter(fn) 筛选出与制定函数返回值匹配的元素集合 (没怎么看懂。)
 
$("div").has("span.red")  匹配出div中所有class为red的span元素
 
 

map()的用法
<p></p>
           < form action= "">
                < input type= "text" name= "name" id= "name" value="用户名" />
                < input type= "text" name= "password" id= "password" value="密码" />
                < input type= "text" name= "content" id= "content" value="这是什么" />
           </ form>
           < script type= "text/javascript">
                 $(function(){
                     $( "p").append($("input" ).map( function(){
                          return $(this).val();
                       }).get().join("."));
                })
            </script>
                                                                                                                                                                                        
 

 
not()执行的是反向操作,能够从jquery对象中删除符合条件的元素并返回这个清洗后的jquery
 
$("ul li").not( ".a").css ("color", "#000000");
 

.slice(start,[end])  第一个参数为必填,如果为负值的话就从尾部开始选取,第一个元素为0,截取时包含start该元素,但不包含end,end元素如果不指定的话,则默认截止到末尾
 

 
 
查找
 
children当为空的时候即选择其下的所有子元素,children()括号里可以设置为“.class”或者“#id”等等
 
contents方法类似于dom中的childNodes。不过contents返回的是一个jquery对象,而childNodes返回的是一个数组
 
原文地址:https://www.cnblogs.com/jldiary/p/5124574.html