HTML DOM Input Submit value Property
Last Updated :
02 Jan, 2024
The Input Submit value Property in HTML DOM is used to set or return the value of the Input Submit Field. The value attribute specifies the text displayed in the Submit Field.Â
Syntax:Â
- It returns the value property.
submitObject.value
- It is used to set the value property.
submitObject.value = text
Property Value: It contains single value text which defines the text displayed in the submit button.Â
Return Value: It returns the string value which represent the text displayed in the submit button.Â
Example 1: This example illustrates how to return the Input Submit value Property.Â
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM Input Submit value Property
</ title >
</ head >
< body style = "text-align:center;" >
< h1 >GeeksforGeeks</ h1 >
< h2 >
HTML DOM Input Submit value Property
</ h2 >
< input type = "submit" id = "GFG"
value = "Submit GFG" >< br >< br >
< button onclick = "myGeeks()" >
Click Here
</ button >
< p id = "result" ></ p >
< script >
function myGeeks() {
let submitVal =
document.getElementById("GFG").value;
document.getElementById("result")
.innerHTML = "Submit Button Value: "
+ submitVal;
}
</ script >
</ body >
</ html >
|
Output:Â
Example 2: This example illustrates how to set the Input submit value Property.Â
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM Input Submit value Property
</ title >
</ head >
< body style = "text-align:center;" >
< h1 >GeeksforGeeks</ h1 >
< h2 >
HTML DOM Input Submit value Property
</ h2 >
< input type = "submit" id = "GFG"
value = "Submit GFG" >< br >< br >
< button onclick = "myGeeks()" >
Click Here
</ button >
< p id = "result" ></ p >
< script >
function myGeeks() {
let submitVal = document.getElementById("GFG")
.value = "Submit@Geeks";
document.getElementById("result")
.innerHTML = submitVal;
}
</ script >
</ body >
</ html >
|
Output:Â
Supported Browsers:
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- OperaÂ
- Safari 1 and above
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...