小白教程
所有教程
关于
Search
172.70.131.17
172.70.131.17
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Sel contains”的源代码
本页内容
上一节:
Jq_sel_focus
下一节:
Sel_has
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE::contains(text)}}[[Category:jquery ref selectors|32]] = jQuery :contains() 选择器 = [[jquery ref selectors|jQuery 选择器]] 选取所有包含 "is" 的 <p> 元素: <sample title="" desc="" lang="html" hererun="1"> $("p:contains(is)") </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p:contains(is)").css("background-color","yellow"); }); </script> </head> <body> <h1>欢迎来到我的主页</h1> <p class="intro">My name is Donald.</p> <p>I live in Duckburg.</p> <p>My best friend is Mickey.</p> <p>你最喜欢的网站:</p> <ul id="choose"> <li>Google</li> <li>Taobao</li> <li>xiaoBai</li> </ul> </body> </html> </run> == 定义和用法 == :contains() 选择器选取包含指定字符串的元素。 该字符串可以是直接包含在元素中的文本,或者被包含于子元素中。 最常见的用法:与其他选择器一起使用,选取指定组合中包含指定文本的元素(如上面的实例)。 '''注意:'''文本是大小写敏感的。 == 语法 == <pre> $(":contains(text)")</pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | text | 必需。规定要查找的文本。 |} [[jquery ref selectors|jQuery 选择器]]
返回至“
Sel contains
”。
上一节:
Jq_sel_focus
下一节:
Sel_has