Home >>jQuery Tutorial >jQuery :contains() Selector
jQuery :contains() selector in jQuery is used to selects elements containing the specified string contained directly in the element as text, or in a child element.
Syntax:$(":contains(text)")
Parameter | Description |
---|---|
text | It is a Required parameter and used to Specifies the text to find |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p:contains(is)").css("background-color", "#97d7fc");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint</h1>
<p class="intro">My name is phptpoint</p>
<p>I live in Noida.</p>
Who is your favourite:
<ul id="choose">
<li>JAVA</li>
<li>jQuery</li>
<li>Javascript</li>
</ul>
</body>
</html>
My name is phptpoint
I live in Noida.
Who is your favourite: