Contains selector selects elements containing the specified string: ($(“:contains(text)”))
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
src="lib/jquery/jquery-1.3.2.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$("p:contains(is)").css("background-color", "red");
});
</script>
</head>
<body>
<h1>This is header one</h1>
<p class="intro">This is paragraph one</p>
<p>This is paragraph two</p>
<p>This is paragraph three</p>
</body>
</html>
Comments
Post a Comment