
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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.
Advertisements