jQuery filter() 方法

jQuery 教程 · 2019-03-28 06:18:45

实例

返回带有类名 "intro" 的所有 <p> 元素:

$("p").filter(".intro")

定义和用法

filter() 方法返回符合一定条件的元素。

该方法让您规定一个条件。不符合条件的元素将从选择中移除,符合条件的元素将被返回。

该方法通常用于缩小在被选元素组合中搜索元素的范围。

提示:filter() 方法是与 not() 方法相对的。

语法

$(selector).filter(criteria,function(index))

参数 描述
criteria 可选。规定要从被选元素组合中返回的选择器表达式、jQuery 对象、一个或多个元素。

提示:如需规定多个条件,请使用逗号分隔。
function(index) 可选。为集合中的每个元素规定要运行的函数。如果返回 true,则保留元素,否则元素将被移除。
  • index - 集合中元素的 index 位置。
注意: this 是当前的 DOM 元素。

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

The Algorithm Design Manual

The Algorithm Design Manual

Steven S Skiena / Springer / 2011-11-14 / GBP 55.07

....The most comprehensive guide to designing practical and efficient algorithms.... Written by a well-known algorithms researcher who received the IEEE Computer Science and Engineering Teaching Aw......一起来看看 《The Algorithm Design Manual》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具