
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Button name Property
The HTML DOM name property returns and alter the value of name attribute of an input button in HTML.
Syntax
Following is the syntax −
1. Returning name
object.name
2. Modifying name
object.name=”text”
Here, “text” represents the new name of the input button.
Example
Let us see an example of name property −
<!DOCTYPE html> <html> <head> <title>HTML DOM name Property</title> <style> body{ text-align:center; } .btn{ display:block; margin:1rem auto; background-color:#db133a; color:#fff; border:1px solid #db133a; padding:0.5rem; border-radius:50px; width:80%; } .show-name{ font-weight:bold; font-size:1.4rem; color:#ffc107; } </style> </head> <body> <h1>name Property Example</h1> <input type="submit" onclick="setName()" class="btn" value="Click me to change my Name attribute value" name="Red_Button"> <div class="show-name"></div> <script> function setName() { var btn= document.querySelector(".btn"); document.querySelector(".show-name").innerHTML ="Previous Name = " + btn.name; document.querySelector(".btn").name = "Round_Red_Button"; } </script> </body> </html>
Output
This will produce the following output -
“Inspect Element” displays the following −
Now, Click on “Click me to change my Name attribute value” to alter the value of name attribute of red button.
Inspect Element −
- Related Questions & Answers
- HTML DOM Button name Property
- HTML DOM Input Button type Property
- HTML DOM Input Button value Property
- HTML DOM Input Button disabled Property
- HTML DOM Input Button form Property
- HTML DOM Input Number name Property
- HTML DOM Input FileUpload name Property
- HTML DOM Input Hidden name Property
- HTML DOM Input Month name Property
- HTML DOM Input Checkbox name Property
- HTML DOM Input Color name Property
- HTML DOM Input Date name Property
- HTML DOM Input Time name Property
- HTML DOM Input URL name Property
- HTML DOM Input Week name Property
Advertisements