I am trying to read the content of a textarea, but .val()
does not work for my textarea.
I would be happy, if someone has a solution for me.
Here's my code:
HTML:
<textarea id="details" class="required" rows="5"></textarea>
JS:
$.ajax({
type: "GET",
url: "reserve.php",
data: {
details : $('#details').val(),
...
},
...
});
Thank you!
We can get the value of textarea in jQuery with the help of val() method . The val() method is used to get the values from the elements such as textarea, input and select. This method simply returns or sets the value attribute of the selected elements and is mostly used with the form elements.
The val() method returns or sets the value attribute of the selected elements. When used to return value: This method returns the value of the value attribute of the FIRST matched element.
This is a valid request, as I have experienced this exact same problem and can report the following:
Yes - there is an answer that isn't a hack or bad code:
$('#myTextArea')[0].value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With