HTML Dom Button Object
The button object represents a button in the HTML document.
This element has no default behavior, but must have an onclick event handle for use.
Each time a <input type = "button"> tag appears in an HTML document, a button object is created.
You can access a button by traversing the elements [] array of the form, or by using document. getelementbyid ().
Definition and usage
The click () method simulates a mouse click on the button.
Syntax
Buttonobject. Click ()
Source: http://www.w3school.com.cn/jsref/dom_obj_button.asp
HTML Dom submit object
The submit object represents a submit button in the HTML form ).
Each time a <input type = "Submit"> tag appears in an HTML form, a submit object is created.
Before the form is submitted, the onclick event handle is triggered, and a handle can cancel the form submission by returning fasle.
See the form. Submit () method and form. onsubmit event handle.
Example: Form Verification
You can access a submit button by traversing the elements [] array of the form, or by using document. getelementbyid ().
Source: http://www.w3school.com.cn/jsref/dom_obj_submit.asp
Differences between submit and button in HTML
Submit is a special case of a button and also a kind of button. It automatically integrates the submit action. If the form needs to be processed (including input verification) by clicking the submit button and then submitted, you must change the submit to the button to cancel the automatic submission. Otherwise, it will result in two submissions. For dynamic web pages, that is, two database operations. Alternatively, return true or false is added for verification when submit is used. You can also use jquery form events for processing. The specifications are as follows:
Jquery event-submit () method definition and usage
When a form is submitted, a submit event occurs.
This event applies only to form elements.
The submit () method triggers the submit event, or specifies the function that runs when a submit event occurs.
Bind a function to the submit event syntax
$(selector).submit(function)
Parameters |
Description |
Function |
Optional. Specifies the function that runs when a submit event occurs. |
Source: http://www.w3school.com.cn/jquery/event_submit.asp
Form submission problems