Selector : * Gets ALL elements


The first jQuery selector that we will look is * which is used to select all elements of the page.
It can be used as follows:
$("*")

Now lets look at an example to clear the concept:
<!--code starts from here-->
<script type='text/javascript'>
$("*").append("#####");
</script>
<p>how r u</p>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>

<!--code ends here-->

When you will execute the above code, you will find that after each element "####" is appended. The output shown is as follows:
how r u##### //this is appended after p tag

* 1##### //these are inserted after li tag
* 2#####
* 3#####
##### // this is inserted after ul tag

Leave a Reply

avatar
  Subscribe  
Notify of