JavaScript DOM Button Object

1. Button Object

  • Button object represents a clickable button in an HTML form.
  • It is used to activate a JavaScript when a user clicks on it.
Syntax:
<input type= “button”>

Button Object Method

MethodDescription
click()It simulates the mouse click on the button but don't mix it up with onClick event handler.

2. Reset Object

  • Reset object represents a reset button in an HTML form.
  • When clicking on a reset button, it resets all the controls within the form to their default values.
Syntax:
<input type= “reset”>

Reset Object Properties

PropertyDescription
LengthIt returns the number of options in a dropdown list.
selectedIndexIt sets or returns the index of the selected option in a dropdown list.
TypeIt returns a type of form element.
nameIt returns the name of the selection list.

3. Submit Object

  • Submit object represents a submit button in an HTML form.
  • It sends the user input in the form to the server.
  • When clicking on a submit button, it fires onSubmit event.
Syntax:
<input type= “submit”>

Submit Object Properties

PropertyDescription
LengthIt returns the number of options in a dropdown list.
selectedIndexIt sets or returns the index of the selected option in a dropdown list.
TypeIt returns a type of form element.
nameIt returns the name of the selection list.