hi i want to insert div element in the root of my page hierarchy, so it must be opened after body tag and closed before body close tag, how can i do it in jquery?
+2
A:
you mean like this?
<body>
<div>
<!-- old contents -->
</div>
</body>
you can do it this way,
$(function(){
$('body').contents().wrapAll('<div>');
});
it seems you have accepted this one so I just want to add something.
you may also add some class to the div you have just added.
like this,
$(function(){
$('body').contents().wrapAll('<div class="someClass"></div>');
});
Reigel
2010-08-26 07:06:31
And suddenly, all becomes sense :p
jAndy
2010-08-26 07:08:45
@jAndy, yeah, but don't worry, at first I did also got the same assumption and got confused by the OP as you did I guess... and maybe I'm still wrong.. ;)
Reigel
2010-08-26 07:10:32