在JQuery中键入将INPUT附加到TEXTAREA [英] Append INPUT to TEXTAREA as being typed in JQuery
本文介绍了在JQuery中键入将INPUT附加到TEXTAREA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个INPUT文本框.
I have an INPUT text box.
当有人在输入"文本框中键入内容时,我需要它在TEXTAREA值的后面添加/添加.
As someone types into the INPUT text box, i need it to append/add-to a TEXTAREA value.
假设用户在文本框中输入"12345".
Lets say user types '12345' into the text box.
textarea(默认值="Comment:")将自动添加:'Comment:12345'.在键入时添加"12345".
The textarea (default value="Comment: ") will automatically add: 'Comment: 12345'. Adding '12345' as they type.
推荐答案
假设area
是您的文本区域的ID,text
是您的文本框的ID,
Assuming area
is the id of your textarea and text
the id of your textbox,
$(function() {
var areaText = $('#area').val();
$('#text').bind('keyup keypress', function() {
$('#area')[0].value = areaText + $(this)[0].value;
});
});
- 此处的示例在URL中添加/edit 以便与示例一起播放
- Working Example here add /edit to the URL to play with the example
这篇关于在JQuery中键入将INPUT附加到TEXTAREA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文