jquery的contains方法

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-3.2.0.js"></script>
</head>
<body>
<h1>Welcome to My Homepage</h1>
<p>My name is Donald</p>
<p>I live in Duckburg</p>
<p>My best friend is Mickey</p>
<script type="text/javascript">
$(document).ready(function(){
$("p:contains(is)").css("background-color","blue");
});
</script>
</body>
</html>

 :contains 选择器选取包含指定字符串的元素。

$(":contains(text)"):text为指定要查找的文本;

该字符串可以是直接包含在元素中的文本,或者被包含于子元素中。

经常与其他元素/选择器一起使用,来选择指定的组中包含指定文本的元素(如上面的例子)。