[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

jQuery: put body inside container div

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
hankknight
Asked:
hankknight
2 Solutions
 
MacAnthonyCommented:
Take a look at wrapInner.

$('body').wrapInner('<div id="container" />');
0
 
leakim971PluritechnicianCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now