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

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

问题描述

我想知道如何使用jquery插入文本到文本区域,点击一个锚标签。



我不想替换textarea中的文本,我想把新的文本添加到textarea中。

  $('a')

.click(function()//这将适用于所有的锚点标签
{
$('#area')。val('foobar'); //这个文本标签的id为'区域'
})

编辑 - 看看下面的

  $('a')。click(function()//这将应用到所有的锚点标签$ b $($#$ b $('#area')。val($('#area')。val()+'foobar'); 
})


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

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

解决方案

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天全站免登陆