开发者

jquery append before final element

I have html structured like so.

<div id='container'>
  <div class='item'> ... </div>
  <div class='item'> ... </div>
  <div class='item'> ... </div>
  ...
  <div id='item_final'><input type="button" id='addOne'>...</div>
</div>

and what I am trying to do it add another item to the container class before the ite开发者_运维问答m_final div. The items are dynamic, so the number of them is unkown.


$('#container div:last').before( $('<div>') );


Try the .insertBefore method.

$('<div>').insertBefore('#item_final');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜