I run a website and there is an area to send messages with AJAX. I’ve noticed that some messages say undefined and therefore people can’t use the message system. The following is the code used to get the value from the text area, whats wrong with it ? I’m thinking that some browsers don’t accept it so how can I fix it? Thanks
<textarea id="message"></textarea>
$('textarea#message').val()
The
val()method get the value attribut, but tag textarea has no value attribut. The text inside Textarea is saved inside the tags<textarea>and</textarea>, so you have to use$('textarea#message').text(). It should work.