jQuery :submit Selector

The jQuery :submit selector selects all the elements with type=”submit” attribute. These are the attributes of the input and the button element. It works only with attribute value as submit and not with the value button.

If you want to select buttons with attribute type=”button”, you have to use the jQuery :button selector.

jQuery :submit Selector

Syntax of jQuery :submit Selector

The syntax of jQuery :submit selector is given below.

Syntax
$(“:submit”)

If you have multiple numbers of forms and the button elements. You can use the selector with the class name and id. It’s helpful when want to select required form elements.

jQuery :submit Selector Selects Input Type Submit Element

If the button is created using the input element in the form. It should be of the attribute type="submit" to select with this selector. After selecting the element, you can highlight by applying CSS.

Example

Test it Live

Output




The above example contains the form with the input type submit element. The selector applies the background yellow color to highlight the selected element. See the yellow-colored button showing the submit button element in a form.

Select Form Button Type Submit Element

In addition to the input type submit element, you can also select the button type submit element. The attribute of the element should be of type="submit". See the example below to select the button element.

Example

Test it Live

Output




The above example contains the orange button element in a form. The selector first selects the button element and then applies the color to it.

I hope you like the above examples of jQuery :submit selector. If you have any queries regarding the above selector, please comment below.

Also tell me, what other methods you are using with the selector by commenting below.

References