Solved

jQuery: put body inside container div

Posted on 2011-09-28
2
292 Views
Last Modified: 2012-06-27
Using jQuery, I want to put everything inside the body inside a container div.

This:
<body>
<div>
<h1>Hello</h1>
<p>World</p>
</div>
</body>

Open in new window


Should become this:

<body>
<div id="container">
<div>
<h1>Hello</h1>
<p>World</p>
</div>
</div>
</body>

Open in new window

0
Comment
Question by:hankknight
2 Comments
 
LVL 11

Accepted Solution

by:
MacAnthony earned 400 total points
ID: 36719375
Take a look at wrapInner.

$('body').wrapInner('<div id="container" />');
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 100 total points
ID: 36720316
Test page : http://jsfiddle.net/UtebB/
var $b = $("body").children();
var $d = $("<div id='container' />").append($b);
$d.appendTo("body");

Open in new window

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now