JQuery Selector All

From CoderLearner
Jump to: navigation, search

Description

Use * to select all HTML elements.

Note

It can be very slow if you don't use it properly.

Example 1

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Select</title>
      <script 
         type="text/javascript" 
         src="/lib/jquery-1.7.2.min.js">				 
      </script>
      <style>
         .markit {
            width: 80px;
            height: 40px;
            float:left;
            padding: 8px;
            margin: 8px;
            border:1px solid #CC6633;
         }
      </style>
      <script>
         $().ready(function() {
            $("body").find("*").addClass("markit");
         });
      </script>
   </head>
   <body> 
      <p>P</p>
      <div>DIV</div>
      <span>SPAN</span>
   </body>
</html>

Try It