Reputation: 9293
I need to clear content of textarea each time user press the ENTER key.
$("#write").keyup(function(event) {
if (event.keyCode == 13) {
$(this).value = "";
$(this).html = "";
$(this).text = "";
}
});
<textarea id="write"></textarea>
Nothing works.
Upvotes: 1
Views: 33
Reputation: 1972
You have done correctly but the missing part only is $(this)[0].value="";
when you use val()
then select object if you use value
then get into the object and use method that is $(this)[0]
Upvotes: 0
Reputation: 68433
try this, use val method to get the value
$("#write").keyup(function(event){
if(event.keyCode == 13){
$(this).val("");
}
});
Upvotes: 2