【问题标题】:Textarea return .val() only if more than 15 chars仅当超过 15 个字符时,Textarea 才返回 .val()
【发布时间】:2012-04-21 16:54:15
【问题描述】:

你能告诉我为什么要用这个表格吗:

<div id="comment-form">
<h3>Commenta questo racconto:</h3>
<form method="post" id="story-comment-form" action="#">
    <textarea name="comment" id="story-comment-text"></textarea>
    <input type="submit" name="vote" class="submit" id="story-comment-submit" title="Invia commento" value="Invia commento"/>
<form>
</div>

还有这个 jquery 代码:

$("#story-comment-submit").click(function(e)
{
    e.preventDefault();
    var a = $("#story-comment-text").val();
    alert(a);
});

var a 仅在 textarea 表单中超过 15 个字符时才返回值?

【问题讨论】:

  • jsfiddle.net/malet/St2FX - 似乎工作正常,您是否还有其他可能干扰的代码?
  • jsfiddle.net/SE2Nq 在 IE、Chrome、Firefox 中尝试过。适用于少于和多于 15 个字符。
  • 这就是所有的形式,我不知道如何使它在 jsfiddle 中工作:jsfiddle.net/cPf7S
  • 你还没有在右边设置正确的 jQuery 库,但即使你这样做了,它仍然对我有用,尽管由于你的 HTML 布局,textarea 中有大约 5 个空格字符。

标签: jquery html textarea


【解决方案1】:

解决了,我遇到了另一个脚本的问题。对不起各位。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    • 2011-06-28
    • 2021-02-03
    • 1970-01-01
    相关资源
    最近更新 更多