JQuery Selector Element

From CoderLearner
Jump to: navigation, search

Description

Select all elements based on the element tag name.

Syntax

$("element")

$("element.class")

$("element#id")

Example 1

<!DOCTYPE html>
<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>
         .mark {
            background-color:green;
         }
      </style>
      <script>
         $().ready(function() {
            $('input').val('XXXX'); 
            $('span').css({'border':'1px solid green',
               'background-color':'yellow'});
         });
      </script>
   </head>
   <body> 
      <form>
         <input type="text" name="first"/><br/>
         <input type="text" name="middle" disabled="disabled"/><br/>
         <input type="text" name="last"/><br/>
         <input type="text" name="age" disabled="disabled"/><br/>
         <input type="text" name="city"/><br/>
      </form>
      <span>It's Great!</span>
      <span>
         <a href="#">jQuery</a>
      </span>
   </body>
</html>

Try It