HTML button name attribute
Examples
Two buttons with the same name, submit a different value when you click on them:
<form action="demo_form.html" method="get">
Choose your favorite subject:
<button name="subject" type="submit" value="HTML">HTML</button>
<button name="subject" type="submit" value="CSS">CSS</button>
</form>
Choose your favorite subject:
<button name="subject" type="submit" value="HTML">HTML</button>
<button name="subject" type="submit" value="CSS">CSS</button>
</form>
try it"
Browser Support
All major browsers support name attribute.
Definition and Usage
name attribute is the name of the button specified.
name attribute is used in JavaScript to reference elements, or after the form is submitted, the form data to be referenced.
Tip: Different button elements can share the same name. This allows you to mark a number of buttons with the same name, to submit different values for use in the form.
Differences between HTML 4.01 and HTML5
NONE.
grammar
<button name="name">
Property Value
值 | 描述 |
---|---|
name | 规定按钮的名称。 |
HTML <button> tag