Home >>jQuery Tutorial >jQuery has() Method

jQuery has() Method

jQuery has() Method

jQuery has() method in jQuery is used to returns all elements that have one or multiple elements inside of them, that matches the specified selector.


Parameter Values

Parameter Description
element It is a Required parameter and is used to specifies a selector expression or an element to match elements agains
Here is an example jQuery has() Method:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
$("p").has("span").css("background-color", "#34eb92");
<h1>Welcome to Phptpoint</h1>
<p>My <span>name</span> is Phptpoint</p>
<p>I live in <span>Noida</span>.</p>
<p>This is my First paragraph</p>


Welcome to Phptpoint

My name is Phptpoint

I live in Noida.

This is my First paragraph

No Sidebar ads