0

我的 html 文件中有一个textarea,我需要将其中的数据发送textarea到数据库。但是,textarea发送没有enter空格的数据。所以这样的数据:

Shortly after reading a few books on web design, I was hooked. I wanted to know everything and anything about it. I was designing websites any chance I could. 

I spent almost all of my savings buying more books on different programming languages and other nerdy computer gear.

在数据库中会是这样的。

Shortly after reading a few books on web design, I was hooked. I wanted to know everything and anything about it. I was designing websites any chance I could. I spent almost all of my savings buying more books on different programming languages and other nerdy computer gear.

所以我决定将 textarea 更改为 ackeditor以将数据作为 html 发送。但是现在我有一个jQuery方法的问题textarea,现在它不起作用了。

HTML:

<td>
<textarea maxlength="5000" id="blah" cols="100" rows="20" name="essay_content" class="ckeditor" onkeyup="words();">
</textarea></td> 

jQuery:

function words(content)
{
    var f = $("#blah").val()
    $('#othman').load('wordcount.php?content='+ encodeURIComponent(f));


}

现在它对我不起作用,因为文本区域是 CkEditor ...有什么建议吗?

4

2 回答 2

0

这应该让您获得 CkEditor 文本区域的内容:

function words(content)
{
    var f = CKEDITOR.instances.blah.getData();
    $('#othman').load('wordcount.php?content='+ encodeURIComponent(f));
}

但是,我认为这onkeyup不会起作用,因为 CkEditor 替换了 textarea。您需要为 CkEditor 创建一个插件,以在编辑器实例中捕获按键触发。

于 2012-07-07T02:23:08.293 回答
0

我用过nlbr,一切正常。

于 2012-07-07T07:32:35.217 回答