The following JavaScript task:

You need to wrap all the content in a div in a body like this:

was: <body> something </body> was: <body><div id="newdiv"> something </div></body>

I tried using window.document.body.insertAdjacentHTML('afterbegin', '<div id="translatebody">') , but the new div is not inserted as I want: <body><div id="newdiv"></div> something </body>

  • You don't need to insert a div, but wrap the content in a div. - Alexey Ukolov
  • Yes, that's right, I corrected the question - Ivan Myasnikov

2 answers 2

 document.body.innerHTML = '<div id="newdiv">' + document.body.innerHTML + '</div>'; 

    If you use jquery, you can do it like this:

     $("body").wrapInner("<div id="newdiv"></div>");