如何将文字附加到'< textarea>'? [英] How to append text to '<textarea>'?

查看:138
本文介绍了如何将文字附加到'< textarea>'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有< textarea> 用户可以在这里向世界输入他的信息!下面,有上传按钮...我想添加上传文件的链接(不用担心,我有它);就在他输入的文本旁边。

I have <textarea> where user can type in his message to the world! Below, there are upload buttons... I would love to add link to uploaded file (don't worry, I have it); right next to the text that he was typing in.

喜欢,他输入'Hello,world!',然后上传文件(通过AJAX完成),以及该文件的链接将添加到< textarea> 的内容的下一行。注意!是否可以将光标(他离开的地方)保存在同一个地方?

Like, he types in 'Hello, world!', then uploads the file (its done via AJAX), and the link to that file is added in next line to the content of <textarea>. Attention! Is it possible to keep cursor (place where he left to type) in the same place?

所有可以用jQuery完成的任何想法?我知道有方法'append()',但它不适用于这种情况,对吗?

All that may be done with jQuery... Any ideas? I know that there are method 'append()', but it won't be for this situation, right?

推荐答案

尝试

var myTextArea = $('#myTextarea');
myTextArea.val(myTextArea.val() + '\nYour appended stuff');

这篇关于如何将文字附加到'&lt; textarea&gt;'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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