Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jQuery: put body inside container div

Posted on 2011-09-28
2
Medium Priority
?
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

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

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

Assisted Solution

by:leakim971
leakim971 earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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…
Suggested Courses

618 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