
- 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 value Property
The HTML DOM value property returns and modify the content of the value attribute of input button.
Syntax
Following is the syntax −
1. Returning value
object.value
2. Modifying value
object.value=”text”
Example
Let us see an example of value property
<!DOCTYPE html> <html> <head> <title>HTML DOM value 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-value{ font-weight:bold; font-size:1.4rem; color:#ffc107; </style> </head> <body> <h1>value Property Example</h1> <input type="submit" onclick="setValue()" class="btn" value="Click me to change my text"> <div class="show-value"></div> <script> function setValue() { var btn= document.querySelector(".btn"); document.querySelector(".show-value").innerHTML ="Previous Value = " + btn.value; document.querySelector(".btn").value = "Congrats! you have successfully changed my value"; } </script> </body> </html>
Output
This will produce the following output −
Click on “Click me to change my text” button to change red button value.
- Related Questions & Answers
- HTML DOM Input Button type Property
- HTML DOM Input Button name Property
- HTML DOM Input Button disabled Property
- HTML DOM Input Button form Property
- HTML DOM Button value Property
- HTML DOM Input Month value Property
- HTML DOM Input FileUpload value Property
- HTML DOM Input Hidden value Property
- HTML DOM Input Checkbox value Property
- HTML DOM Input Color value Property
- HTML DOM Input Date value Property
- HTML DOM Input Time value Property
- HTML DOM Input Text value Property
- HTML DOM Input Email value Property
- HTML DOM Input URL value Property
Advertisements