jQuery API 返回首页目录 | jQuery API 中英文对照版
contains(str)
contains(str)

把元素集合筛选为包含指定文本(区分大小写)的元素。

返回值:jQuery

参数:

  • str (String): 包含在元素中的文本

示例:

$("p").contains("test")

HTML 代码:

<p>This is just a test.</p><p>So is   this</p>

结果:

[ <p>This is just a test.</p> ] 
 
contains( str )

Filter the set of elements to those that contain the specified text.

Return value: jQuery
Parameters:

  • str (String): The string that will be contained within the text of an element.

Example:

 $("p").contains("test")  
Before:
 <p>This is just a test.</p><p>So is this</p>  
Result:
 [ <p>This is just a test.</p> ]  
相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog