Home  >  jQuery

Example of :contains() Selector in jQuery

April 29, 2013
:contains() Selector is used on any DOM element. As arguments it takes any text and then it searches for that text within the calling element. Syntax is
$("p:contains('jQuery')")
 
Find the example.

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<p>We are at jQuery page.</p>
<p>We can learn a lot here.</div>
<p>jQuery is write less , do more</p>

<script>
$("p:contains('jQuery')").css("color", "blue");</script>
</body>
</html>
 

Output

We are at jQuery page.

We can learn a lot here.

jQuery is write less , do more

FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us