THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Button name Property

Button Object Reference Button Object

Example

Return the value of the name attribute of a button:

var x = document.getElementById("myBtn").name;

The result of x will be:

myname
Try it yourself »

Definition and Usage

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

Internet Explorer Firefox Opera Google Chrome Safari

The name property is supported in all major browsers.


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 Reference Button Object