Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

HTML | DOM value Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The DOM value property in HTML is used to set or return the value of any attribute.

  • It returns the attribute value. 
  • It is used to set a value to the property. 
attribute.value = value

Property Value: 

  • value: It defines the value of the attribute.

Return Value:  It returns a string value which represents the value of the attribute. 

Below program illustrates the DOM value property in HTML:


<!DOCTYPE html>
            DOM Value Property
        <!-- script to change property value -->
            function myFunction() {
                var x = document.getElementsByTagName("IMG")[0];
                x.getAttributeNode("src").value =
    <body style = "text-align:center">
        <h1 style = "color:green;">
        <h2>DOM Value Property</h2>
        <img src =
        width="180" height="180">
           Click the button to change the value
           of attribute "src" of the image.
        <!-- Button to change DOM value property -->
        <button onclick = "myFunction()">
            Try it

Before Click on the button: 

After clicking on the button: 

Supported Browsers: The browser supported by DOM value property are listed below: 

  • Google Chrome 62 and above
  • Edge 14 and above
  • Internet Explorer not supported
  • Firefox 22 and above
  • Opera 49 and above
  • Safari 10 and above


My Personal Notes arrow_drop_up
Last Updated : 12 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials