jQuery Selector How to - Finds all button inputs








Question

We would like to know how to finds all button inputs.

Answer


<!--  www  .  j  av a 2 s .  c  o m-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $(":button").css({background:"yellow", border:"3px red solid"});
        });
    </script>
  </head>
  <body>
    <body>
        <input type="button" value="Input Button"/>
    
        <input type="checkbox" />
        <input type="file" />
        <input type="hidden" />
        <input type="image" />
        <input type="password" />
        <input type="radio" />
        <input type="reset" />
        <input type="submit" />
        <input type="text" />
    
        <select><option>Option<option/></select>
        <textarea></textarea>
        <button>Button</button>
    </body>
</html>

The code above is rendered as follows: