使用 jQuery 将文本插入 textarea [英] Insert text into textarea with jQuery

查看:27
本文介绍了使用 jQuery 将文本插入 textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在单击锚标记时使用 jquery 将文本插入文本区域.

I'm wondering how I can insert text into a text area using jquery, upon the click of an anchor tag.

我不想替换 textarea 中已有的文本,我想将新文本附加到 textarea.

I don't want to replace text already in textarea, I want to append new text to textarea.

推荐答案

从 Jason 的评论中尝试:

From what you have in Jason's comments try:

$('a').click(function() //this will apply to all anchor tags
{ 
   $('#area').val('foobar'); //this puts the textarea for the id labeled 'area'
})

编辑-要附加到文本,请看下面

Edit- To append to text look at below

$('a').click(function() //this will apply to all anchor tags
{ 
   $('#area').val($('#area').val()+'foobar'); 
})

这篇关于使用 jQuery 将文本插入 textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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