jQuery Selector How to - Select submit button








Question

We would like to know how to select submit button.

Answer


<!--  w  w  w  . java  2  s.co 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(){
       var input = $(":submit");
       $('#result').text('jQuery matched ' + input.length + ' elements.');
    });
    </script>
  </head>
  <body>
     <form><input type="submit" /></form>
     <div id="result"></div>
  </body>
</html>

The code above is rendered as follows: