开发者

Append before last tag?

开发者 https://www.devze.com 2023-04-09 06:17 出处:网络
Here\'s my HTML: <section> <article></article> <article></article> <!-- INSERT HERE -->

Here's my HTML:

<section>
   <article></article>
   <article></article>
   <!-- INSERT HERE -->
   <footer></footer>
</section>

How would I insert content after the last article but before the footer?

I've tried doing this:

$('<article>Yipee</article>').appendTo('section 开发者_StackOverflow中文版article:last');

But that inserts the new article inside the last one instead of as a sibling.

I'm running jQuery 1.6.2.


insertAfter is the function your are looking for I think:

$('<article>Yipee</article>').insertAfter('section article:last');
0

精彩评论

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