Chonchol Mahmud Chonchol Mahmud - 6 months ago 31
Javascript Question

reset is not a function in JavaScript

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 error when i click on
reset
button.

Error:


Uncaught TypeError: document.getElementById(...).reset is not a
function


Where is the problem? Thanks in advanced.
N.B: i was not using
form
tag.

Answer

You should use

document.getElementById("textareaInput").value = "";
Comments