开发者

Append before last tag?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜