* Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:all

Description

jQuery * Selector selects all elements in the document, including html, head and body.

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("body *").css("background-color", "red");
});//  w  ww  .j  av a2s .  c o m
</script>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<p class="intro">This is a test.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>

<p>Who is your favourite:</p>
<ul id="choose">
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>

</body>
</html>

Related Tutorials