JQuery wrap div around massive HTML block

I was looking for .wrap(), .append(), .wrapall()and .insertAfter()and found solutions. I would like to take a new one divand wrap it around an html block. I don't have access to HTML, so I need to use jQuery.

The function .insertAfter()was perfect, but unfortunately it automatically closes the html tags.

The root of the problem is that I need to center two separate ones divthat do not have access to their HTML.

$(function () {  
    $('<div id="centerContainer">').insertAfter('#header');
    $('</div><!-- centerContainer -->').insertAfter('#footer');
});
+4
source share
1 answer

, DOM , .insertAfter() DOM , , .wrapAll() .

( ) #header #footer ( ) , .nextUntil() #header #footer, .wrapAll() :

$('#header').nextUntil('#footer').wrapAll('<div id="centerContainer"></div>');
+4

All Articles