Oli*_*sen 45 html jquery text add
如何将文本从DIV添加到textarea?
我现在有这个:
$('.oquote').click(function() {
$('#replyBox').slideDown('slow', function() {
var quote = $('.container').text();
$('#replyBox').val($('#replyBox').val()+quote);
// Animation complete.
});
});
Run Code Online (Sandbox Code Playgroud)
Ali*_*guy 66
只是append()文本节点:
$('#replyBox').append(quote);
Run Code Online (Sandbox Code Playgroud)
Fel*_*ing 36
这应该工作.如果将函数传递给val:
$('#replyBox').val(function(i, text) {
return text + quote;
});
Run Code Online (Sandbox Code Playgroud)
这样您就可以避免搜索元素并调用val两次.