Form Submit button (input:submit)

Description and Syntax

$(":submit")

selects all submit inputs and button elements (<input type="submit">, <button>)

Examples

The following code counts the submit buttons.


<html>
  <head>
    <script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){<!--from  w  ww .j  a  v a2s .c o  m-->
            alert($(":submit").length);
        });
    </script>
  </head>
  <body>
    <body>
    <form>
        <input type="button" value="Input Button"/>
        <input type="checkbox">java2s.com</input>
        <input type="checkbox" />
        <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>
    </form>    
    </body>
</html>

Click to view the demo

The code above generates the following result.

Form Submit button (input:submit)

Select the submit button

The following code get the submit button


<html>
  <head>
    <script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){<!-- www .jav a 2s.com-->
       var input = $(":submit");
    
       $('#result').text('jQuery matched ' + input.length + ' elements.');
        
    });
    </script>
  </head>
  <body>
     <form><input type="submit" /></form>
     <div id="result"></div>


  </body>
</html>

Click to view the demo

The code above generates the following result.

Form Submit button (input:submit)