I want to clear my textarea field using following method.
Here is my code :
<form id="localStorageTest" action="" method="post">
<textarea cols="100000" rows="100000" style="height: 150px; width: 200px;" readonly="readonly" name="hhhh" id="txt1"></textarea>
<textarea cols="1000" rows="100000" style="height: 20px; width: 190px;" name="txtarea" id="txt3" class="stored"></textarea>
<input type="button" name="button" onclick="insertdata(txtarea.value)" value="send"/>
</form>
I want to clear the field of which id txt3. I have done this as following ..
$('#txt3').button(function() {
localStorage.clear();
})
But it do not work. Where or what is problem in my code.
Please anyone help me.
Thanks in advance.
Your code will cause errors. I don’t know what you are trying to do? Clicking on the button should clear the textarea. Why the onclick attribute then?
You should assign an id to your button. It’s easier to select it
I assume you are using jquery, so:
HTML:
JS: