HTML | DOM value Property
The DOM value property in HTML is used to set or return the value of any attribute.
Syntax:
- It returns the attribute value.
attribute.value
- It is used to set a value to the property.
attribute.value = value
Below program illustrates the DOM value property in HTML:
Example:
<!DOCTYPE html> <html> <head> <title> DOM Value Property </title> <!-- script to change property value --> <script> function myFunction() { var x = document.getElementsByTagName("IMG")[0]; x.getAttributeNode("src").value = } </script> </head> <body style = "text-align:center"> <h1 style = "color:green;"> GeeksforGeeks </h1> <h2>DOM Value Property</h2> <img src = width="180" height="180"> <p> Click the button to change the value of attribute "src" of the image. </p> <!-- Button to change DOM value property --> <button onclick = "myFunction()"> Try it </button> </body> </html> |
chevron_right
filter_none
Before Click on the button:

After clicking on the button:

Supported Browsers: The browser supported by DOM value property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM specified Property
- HTML | DOM name Property
- HTML | DOM URL Property
- HTML | DOM li value Property
- HTML | DOM dir Property
- HTML | DOM id Property
- HTML | DOM Bdo dir Property
- HTML | DOM Progress max Property
- HTML | DOM title Property
- HTML | DOM documentElement Property
- HTML | DOM offsetWidth Property
- HTML | DOM referrer Property
- HTML | DOM defaultView Property
- HTML | DOM Input URL value Property
- HTML | DOM IFrame name Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



