Espen Arnoy
Espen Arnoy

Reputation: 157

access textarea value

I have a on a form of mine. I´m trying to reset the value (the value typed by the user) of this field on a certain event. However, I seem unable to access it both with .val() and .html().

Any advice on this?

Upvotes: 0

Views: 580

Answers (3)

Tomalak
Tomalak

Reputation: 338128

Do not use .html(), use .val().

$("#your_textarea_id").val("Some literal <textarea> content.");

This way special characters (<, > etc) will show up correctly.

Upvotes: 5

newinjs
newinjs

Reputation: 140

$('#text_area').val("");

Upvotes: 1

baloo
baloo

Reputation: 7755

Set an id on that field so you can easily target it with $('#the_id'). If it's a textarea use .text(''), input use .val('')

Upvotes: 1

Related Questions