开发者

how to append on sibling in jQuery?

开发者 https://www.devze.com 2023-03-08 14:27 出处:网络
I have this code <div class=\"data\">开发者_JAVA技巧 <div class=\"another\"> </div>

I have this code

<div class="data">开发者_JAVA技巧

<div class="another">
</div>
<!-- need to add element here -->

</div>

I want to add the element where I put comment using jQuery how I can append sibling of another using jQuery


If you specifically want to insert after the another div element, try insertAfter:

$('<div>Another 2</div>').insertAfter($('.another'));

In the $('.another') part, you can otherwise specify the target more precisely.


I think you want to use the .after() function:

$('div.another').after('<div>');


try:

$('div#data').append('your HTML');
0

精彩评论

暂无评论...
验证码 换一张
取 消