JavaScript Kit > JavaScript Reference > Here

Button Object

Last updated: June 20th, 2004

Form buttons (<input type="button">) within your form can be accessed and manipulated using JavaScript via the corresponding Button object. To access a button in JavaScript, use the syntax:

document.myform.buttonname //where myform and buttonname are names of your form/element.
document.myform.elements[i] //where i is the position of the button within form

Related Tutorials


Events Description
onClick Code is executed when user clicks on the button. Example(s).


Properties Description
accessKey String value that sets/ returns the accessKey for the button.
disabled Boolean value that sets/ returns whether the button is disabled.
form References the form that contains the reset button.
name Reflects the name of the button (the name attribute).
type A property available on all form elements, "type" returns the type of the calling form element, in this case, "button".
value A read only string that specifies the value of the button.


Methods Description
blur() Removes focus away from the button.
click() Simulates a user clicking on the form button.
focus() Sets focus on the button.



This example creates a form button that goes to a URL when clicked on.

<input type="button" onClick="window.location=''" value="Dynamic Drive" />

Reference List

Right column

CopyRight (c) 2015 JavaScript Kit. NO PART may be reproduced without author's permission. Contact Info