E.g:
<div class="cloneMyself">clone my self and plus more text</div>
<div class="clickMe">add more info to cloneMyself</div>
$('.clickMe').click(function(){
$('.cloneMyself').text(// here I want it to be clonMyself's text plus extra info);
});
然后当我点击clickMe
时,我需要cloneMyself's
文字:
原文+新文字
clone my self and plus more text from here was added after click it.
非常感谢!!
答案 0 :(得分:0)
您可以使用回调(请参阅docs获取信息)查询当前元素的.text()
:
$('.clickMe').click(function() {
$('.cloneMyself').text(function() {
return $(this).text() + " extra info";
});
});
答案 1 :(得分:0)
试试这个:
$('.clickMe').click(function(){
$('.cloneMyself').text($('.cloneMyself').text() + "some extra info");
});