开发者

jquery insert div element which will include all old body content

hi i want to insert div e开发者_如何转开发lement 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?


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>');
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜