jq 笔记二filter()用法

filter的参数类型可分为两种: 

1 传递选择器 

2 传递过滤函数 

如果使用选择器作为参数,用法如下 

$('a').filter('.external')   匹配a中含有class 是external的


使用匿名过滤函数 

$('a').filter(function(index) { 
return $(this).hasClass('external'); 匹配a中含有class 是external的
}) 


参数index是结果集的下标.

filter 查找匹配的是当前元素

猜你喜欢

转载自www.cnblogs.com/jjchi/p/9886642.html
jq