I'm wondering is there a way to convert this:
<body>
Foo
Bar
<div>Abc</div>
<div>Xyz</div>
</body>
To this:
<body>
<div id="new">
Foo
Bar
</div>
<div>Abc</div>
<div>Xyz</div>
</body>
As a novice, I know basic things about innerHTML
and jQuery wrap
, but code like this one:
var foo = document.body.innerHTML;
console.log(foo);
gives me the full body, include Abc
and Xyz
divs. So, it doesn't resolve the problem.