jquery contains选择器 语法
作用::contains 选择器选取包含指定字符串的元素。该字符串可以是直接包含在元素中的文本,或者被包含于子元素中。经常与其他元素/选择器一起使用,来选择指定的组中包含指定文本的元素(如上面的例子)。
语法:$(":contains(text)")
参数:text 必需。规定要查找的文本。 大理石平台怎么样
jquery contains选择器 示例
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p:contains(is)").css("background-color","#B2E0FF"); }); </script> </head> <body> <html> <body> <h1>Welcome to My Homepage</h1> <p class="intro">My name is Donald</p> <p>I live in Duckburg</p> <p>My best friend is Mickey</p> <div id="choose"> Who is your favourite: <ul> <li>Goofy</li> <li>Mickey</li> <li>Pluto</li> </ul> </div> </body> </html> </body> </html>