Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

append div before last child in jQuery 1.3

Tags:

jquery

I am using jquery 1.3.(x) (don't remember the exact version name).
I have a variable holder that contains elements.
I would like to add a div at the n-1 position inside holder.
In jquery 1.4 I can do holder.children().last().before('<div />');.
How can I do it using jquery 1.3?

like image 441
Naor Avatar asked May 03 '11 17:05

Naor


1 Answers

Try this:

$("<div>New DIV</div>").insertBefore($(":last-child", holder));

Working Example: http://jsfiddle.net/Chandu/u94gV/

like image 85
Chandu Avatar answered Sep 21 '22 03:09

Chandu