jQuery has() by element name

Description

jQuery has() by element name

View in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").has("b,span").css("background-color", "yellow");
});/*  w  ww . ja v  a2s. com*/
</script>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<p>My <span>name</span> is CSS.</p>
<p>This is a <span>test</span>.</p>
<p>This <b>is</b> another test..</p>
</body>
</html>



PreviousNext

Related