1 Example(s) of JQuery Has


Description :

The has() method returns all elements that have one or more elements inside of them,The has() method returns all the elements which matches at least one of the elements passed to this method. The has() method accepts a mandatory parameter which reduces the matched set of elements.

Syntax : $(selector).has(element)


JQuery Has Example - 1
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").has("b,span").css("background-color", "cyan");
});
</script>
</head>
<body>

<h1>Welcome to Appwrk team</h1>

<p><span>APPWRK IT</span> Solutions.</p>
<p>Company offering <span>customer-oriented</span> web design services .</p>
<p>We strive for continuous improvement in all aspects of our work</p>

</body>
</html>

Output