The following code works for me:
var div2 = document.createElement('DIV');
$(div2).css('position','relative').insertBefore( $(div).children()[0] );
var div3 = document.createElement("DIV");
$(div2).prepend($(div3).css({'display':'inline','position':'absolute'}));
...but I got to imagine there is a neater jQuery way to do the createElement's. I tried the following, but it didn't work:
$('<div></div>').css('position','relative').insertBefore( $(div).children()[0] );
$(div2).prepend($('<div></div>').css({'display':'inline','position':'absolute'}));
Any sugestions?
You can use the
$("<div></div>")
syntax to create elements without using document.createElement('div');This works perfectly, (please check on fiddle http://jsfiddle.net/P5A8L/1/ ) your error may come from the undefined variables
div
anddiv2