Naor
Naor

Reputation: 24103

append div before last child in jQuery 1.3

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?

Upvotes: 6

Views: 7837

Answers (1)

Chandu
Chandu

Reputation: 82943

Try this:

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

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

Upvotes: 12

Related Questions