JQuery:.val()不适用于textarea
问题描述:
我正在尝试阅读textarea的内容,但 .val()
对我的textarea不起作用。
如果有人为我提供解决方案,我会很高兴。
这是我的代码:
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(),
...
},
...
});
谢谢!
答
val()
工作得很好......你必须在其他地方出错。
val()
works just fine... You must have your error elsewhere.
Example
可能你的选择器不匹配。检查拼写错误以及是否应用了正确的前缀(#
用于ID或。
用于类)
Probably your selector in not matching. Check for typos and if you applied the correct prefix (#
for ID or .
for class)