2011-09-28 43 views
2

這裏是我的HTML:在最後一個標籤之前追加?

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

我怎麼會插入最後article後,但在此之前的footer內容?

我試着這樣做:

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

但是,插入新article最後一個內,而不是作爲同級。

我正在運行jQuery 1.6.2。

回答

5

insertAfter是你正在尋找我的函數想:

$('<article>Yipee</article>').insertAfter('section article:last'); 
相關問題