JQuery:.val()不适用于textarea [英] JQuery: .val() is not working for textarea

查看:131
本文介绍了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)

这篇关于JQuery:.val()不适用于textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆