The value
property sets or gets the value attribute of the reset button.
The value
attribute sets the text that is displayed on the reset button.
value |
Yes | Yes | Yes | Yes | Yes |
Return the value property.
var v = resetObject.value
Set the value property.
resetObject.value=text
Value | Description |
---|---|
text | The text displayed on the reset button |
A String type value representing the text displayed on the reset button.
The following code shows how to get the text displayed on a Reset button.
<!DOCTYPE html>
<html>
<body>
<!-- ww w . j av a 2 s . c o m-->
<input type="reset" id="myReset" value="Reset form">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myReset").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to change the text displayed on a Reset button.
<!DOCTYPE html>
<html>
<body>
<!--from w ww . ja v a 2 s. c om-->
<input type="reset" id="myReset" value="Reset form">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("myReset").value = "newResetButtonValue";
}
</script>
</body>
</html>
The code above is rendered as follows: