Button name Property
Example
Return the value of the name attribute of a button:
var x = document.getElementById("myBtn").name;
Try it Yourself »
Description
The name property sets or returns the value of the name attribute of a button.
The name attribute specifies the name of a button, and is used to reference form data after it has been submitted, or to reference the element in a JavaScript.
Browser Support
Property | |||||
---|---|---|---|---|---|
name | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the name property:
buttonObject.name
Set the name property:
buttonObject.name = name
Property Values
Value | Description |
---|---|
name | Specifies the name of the button |
Technical Details
Return Value: | A String, representing the name of the button |
---|
More Examples
Example
Change the value of the name attribute of a button:
document.getElementById("myBtn").name = "newButtonName";
Try it Yourself »
Related Pages
HTML reference: HTML <button> name attribute
❮ Button Object