我有这个代码
<div class="data">
<div class="another">
</div>
<!-- need to add element here -->
</div>
Run Code Online (Sandbox Code Playgroud)
我想添加使用jQuery放置注释的元素我如何使用jQuery追加另一个兄弟
Ale*_* R. 43
如果您特意想在another div元素后插入,请尝试insertAfter:
$('<div>Another 2</div>').insertAfter($('.another'));
Run Code Online (Sandbox Code Playgroud)
在$('.another')零件中,您可以更精确地指定目标.
Ric*_*ton 37
我想你想使用.after()函数:
$('div.another').after('<div>');
Run Code Online (Sandbox Code Playgroud)
尝试:
$('div#data').append('your HTML');
Run Code Online (Sandbox Code Playgroud)