I have been all over this site but have not found my answer. I am trying to wrap all divs into one wrapper. All I have been able to do so far using wrapAll is to add a container around each div. I don't want to do that. I have this
<div class="container-fluid">
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
</div><!--END container-fluid-->
I need to turn it into this
<div class="container-fluid">
<div class="container">
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
</div><!--END container-->
</div><!--END container-fluid-->
Is this possible to do with Jquery?
Here you go with a solution https://jsfiddle.net/woLzgvok/
$(".panel-cell").wrapAll("<div class='container'></div>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid">
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
<div class="panel-cell">Content</div>
</div><!--END container-fluid-->
WrapAll Documentation
.wrapAll API in jquery does this
$(".panel-cell").wrapAll("<div class='container'></div>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With