JQuery Selector button

From CoderLearner
Jump to: navigation, search

Description

Select all button elements and elements of type button.

Syntax

$(':button');

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>
         .marked {color:red; }
      </style>
      <script>
         $().ready(function() {
            $(':button').addClass('marked');
         });
      </script>
   </head>
   <body> 
      <form method="post" action="test.php">
         <table border="0">
            <tr>
               <td>
                  First Name
               </td>
               <td>
                  <input type="text" name="fname" size="20" maxlength="20"/>
               </td>
            </tr>
            <tr>
               <td>
                  Last Name
               </td>
               <td>
                  <input type="text" name="lname" size="20" maxlength="20"/>
               </td>
            </tr>
            <tr>
               <td>
                  Email
               </td>
               <td>
                  <input type="text" name="email" size="20" maxlength="20"/>
               </td>
            </tr>
            <tr>
               <td colspan="2"> <input type="button" value="Check"/></td>
            </tr>
         </table>
      </form>
   </body>
</html>

Try It