HTML | DOM Input Image value Property
The Input Image value Property in HTML DOM is used to sets or returns the value of the value attribute of the Input Image.
Syntax:
- It returns the value Property.
imageObject.value
- It sets the value Property.
imageObject.value = value;
Property Value It contains the value text Which specify the value of the input Image
Return Value It returns a numeric value which represents the value of the Input Image.
Example: This Example returns the Input Image value Property.
<!DOCTYPE html> < html > < head > < title > HTML DOM Input Image value Property </ title > </ head > < body style = "text-align:center;" > < h1 style = "color:green;" > GeeksForGeeks </ h1 > < h2 >DOM Input Image value Property</ h2 > < button onclick = "my_geek()" > < input id = "myImage" value = "myGeeks" type = "image" src = alt = "Submit" formaction = "#" formtarget = "#" formenctype = "text/plain" width = "48" height = "48" > </ button > < h2 id = "Geek_h" style = "color:green;" > </ h2 > < script > function my_geek() { // Return formTarget, // formEnctype and formAction. var txt = document.getElementById( "myImage").value; document.getElementById( "Geek_h").innerHTML = txt; } </ script > </ body > </ html > |
Output:
Before Clicking On Button:
After Clicking On Button:
Example-2: This Example sets the Input Image value Property.
<!DOCTYPE html> < html > < head > < title > HTML DOM Input Image value Property </ title > </ head > < body style = "text-align:center;" > < h1 style = "color:green;" > GeeksForGeeks </ h1 > < h2 >DOM Input Image value Property</ h2 > < button onclick = "my_geek()" > < input id = "myImage" value = "myGeeks" type = "image" src = alt = "Submit" formaction = "#" formtarget = "#" formenctype = "text/plain" width = "48" height = "48" > </ button > < h2 id = "Geek_h" style = "color:green;" > </ h2 > < script > function my_geek() { // Return formTarget, // formEnctype and formAction. var txt = document.getElementById( "myImage").value = "Hello Geeks"; document.getElementById( "Geek_h").innerHTML = "The value was changed to " + txt; } </ script > </ body > </ html > |
Output:
Before Clicking On Button:
After Clicking On Button:
Supported Browsers: The browsers supported by DOM Input Image value Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | DOM Input Image alt Property
- HTML | DOM Input Image name Property
- HTML | DOM Input Image src Property
- HTML | DOM Input Image type Property
- HTML | DOM Input Image formEnctype Property
- HTML | DOM Input Image formTarget Property
- HTML | DOM Input Image width Property
- HTML | DOM input image height Property
- HTML | DOM Input Image form Property
- HTML | DOM Input Image formNoValidate Property
- HTML | DOM Input Image disabled Property
- HTML | DOM Input Image formAction Property
- HTML | DOM Input Image formMethod Property
- HTML | DOM Input image autofocus Property
- HTML | DOM Input Image Object
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.