Skip to content Skip to sidebar Skip to footer

Wrap Some Divs With Two Different Columns

I've these divs
-115
-91
-99

Solution 1:

You should use class instead of id here and then you can use wrapAll

$('.content').each(function() {
  $(this).find(".lpost").wrapAll('<div class="left_columns"></div>')
  $(this).find(".rpost").wrapAll('<div class="right_columns"></div>')
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="content">
  <div class="rpost">-115</div>
  <div class="lpost">-91</div>
  <div class="lpost">-99</div>
  <div class="rpost">-181</div>
  <div class="lpost">-19</div>
  <div class="rpost">-135</div>
  <div class="rpost">-85</div>
  <div class="lpost">-39</div>
</div>

Post a Comment for "Wrap Some Divs With Two Different Columns"