jQuery Selector * (asterisk)

Description

jQuery Selector * (asterisk)

$("*")

The * selector selects all elements in the document, including html, head and body.

If the * selector is used with another element, it selects all child elements within the specified element.

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(){
  $("*").css("background-color", "yellow");
});//from   w  ww  .jav  a 2  s.c o  m
</script>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<p class="myClassSelector">This is a test.</p>
<p>I am from java2s.com.</p>
<p>This is another test.</p>

<p>Who is your favourite:</p>

<ul id="choose">
  <li>Javascript</li>
  <li>HTML</li>
  <li>CSS</li>
</ul>

</body>
</html>



PreviousNext

Related