Home >>jQuery Tutorial >jQuery :has() Selector

jQuery :has() Selector

jQuery :has() Selector

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


Parameter Values

Parameter Description
selector It is a Required parameter and used to specifies the element to select.
Here is an Example of jQuery :has() Selector

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
$("p:has(span)").css("border", "solid #97d7fc");
<p><span>span element inside a p element.</span></p>
<p>p element with no span element.</p>


span element inside a p element.

p element with no span element.