<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
console.log($("p:contains(雷锋)"));
var $option = $("p:contains(雷锋)").map(function(){
if ($(this).text() == "雷锋") {
//return this;
$(this).css("background-color","yellow");
}
});
console.log($option);
//$("p:contains(雷锋)").css("background-color","yellow");
});
</script>
<h1>欢迎来到这里!</h1>
<p>雷锋</p>
<p>雷锋塔</p>
</body>
</html>
jq:contains函数精确匹配
最新推荐文章于 2024-09-09 09:35:48 发布