Select element by containing text
Description
The following code shows how to select element by containing text.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {<!--from w w w . java 2s. c o m-->
$("div:contains('J')").css("text-decoration", "underline");
});
</script>
<style>
div {
background: yellow;
width: 80px;
height: 80px;
margin: 5px;
float: left;
}
</style>
</head>
<body>
<div>Java</div>
<div>C#</div>
<div>JavaScript</div>
<div>CSS</div>
<div>Ja va2s.com</div>
<div>ja va2s.com</div>
<div>Java2s.com</div>
</body>
</html>