Button nameProperty

Button 对象参考手册Button Object

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. It is often used to reference data in the backend dynamic language after form submission, or to reference elements in JavaScript. /p>

Syntax

buttonObject.name=name


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the name attribute.


Example

Example

Return the value of the button's name attribute:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
</head>
<body>

<button id="button1" name="button1">Click me!</button>
<p>The name of the button:
<script>
document.write(document.getElementById("button1").name);
</script></p>

</body>
</html>

Try it Yourself »


Button 对象参考手册Button Object Other Extensions