Here is my code what i was trying: Markup:
<textarea class="form-control textareaInput" rows="12" id="textareaInput"></textarea>
<div class="row">
<div class="col-lg-2 text-center">
<div class="form-group">
<button class="form-control btn btn-primary reset" onclick="myFunction()">Reset</button>
</div>
</div>
</div>
My function:
function myFunction() {
//alert("ok");
document.getElementById("textareaInput").reset();
}
I am getting errors when I click on the reset button.
Error:
Uncaught TypeError: document.getElementById(...).reset is not a function
Where is the problem?
N.B: I was not using the form tag.
reset()requires aHTMLFormElement: developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/resetreset()DOM node method offormelement set values of any descendant ':input' to default one, not to empty string.