From jQuery JavaScript Library
« Back to Selectors
:contains(text)
Matches elements which contain the given text.
Arguments:| text | String | |
|---|
| A string of text to look for. It's case sensitive. |
Examples:| Name | Type |
Finds all divs containing "John" and underlines them.
$("div:contains('John')").css("text-decoration", "underline");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div:contains('John')").css("text-decoration", "underline");
});
</script>
</head>
<body>
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn
</body>
</html>