Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to wrap table rows without duplicating my wrapper div's?
    primarykey
    data
    text
    <p>I have following code that will be generated by Wordpress:</p> <pre><code>&lt;h3&gt; &lt;span class="title"&gt;General Settings:&lt;/span&gt; &lt;/h3&gt; &lt;table class="form-table"&gt; &lt;tbody&gt; &lt;div class="section_box1"&gt;&lt;tr class="section1" valign="top"&gt; &lt;th scope="row"&gt;Hide Menu Background:&lt;/th&gt; &lt;td&gt; &lt;input id="" checked="" name="" type="checkbox"&gt; &lt;/td&gt; &lt;/tr&gt;&lt;tr class="section1" valign="top"&gt; &lt;th scope="row"&gt; Menu Background: &lt;/th&gt; &lt;td&gt; &lt;input name="" type="file"&gt; &lt;/td&gt; &lt;/tr&gt;&lt;/div&gt; &lt;div class="section_box2"&gt;&lt;tr class="section2" valign="top"&gt; &lt;th scope="row"&gt;Hide Sidebar:&lt;/th&gt; &lt;td&gt; &lt;input id="" checked="" name="" type="checkbox"&gt; &lt;/td&gt; &lt;/tr&gt;&lt;tr class="section2" valign="top"&gt; &lt;th scope="row"&gt;Hide Site Title:&lt;/th&gt; &lt;td&gt; &lt;input id="" checked="" name="" type="checkbox"&gt; &lt;/td&gt; &lt;/tr&gt;&lt;/div&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>For now there will be two sections (tr.section1 &amp; tr.section2). <br/>Now I will wrap these sections with two div's (.section_box1 &amp; .section_box2).</p> <p><br/>So I am using following Jquery:</p> <pre><code>//Lets wrap those two sections inside divs ... $('tr.section1').not($('tr').eq(1)).each(function(){ $(this).add($(this).nextUntil('.section2')).wrapAll('&lt;div class="section_box1"&gt;&lt;/div&gt;'); }); $('tr.section2').not($('tr').eq(3)).each(function(){ $(this).add($(this).nextUntil('.section3')).wrapAll('&lt;div class="section_box2"&gt;&lt;/div&gt;'); }); </code></pre> <p>Now the problem with this code is: If I add another setting field (checkbox for example) in my sections my wrapper div's (section_box1 &amp; section_box2) will duplicate (obviously I want to avoid that). <br/><br/>I have created <a href="http://jsfiddle.net/QZKJM/" rel="nofollow"><b>This Fiddle</b></a> to show you my problem. <br/> <br/>So how can I properly wrap my sections without duplicating my wrapper div's and still be able to add more fields inside wrapper div's section_box1 &amp; section_box2? <br/>I am trying to make this for couple of hours now but no luck:( <br/><br/>Thank you guys in advance!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload