Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery each count issue
    text
    copied!<p>I'm trying to display count within the 'dt' wrap of each person but at the moment its displaying count between everyone in and outside the 'dt' wrap. I've attached a screen print. if anyone can advice me on this fix I'd greatly appreciate it. </p> <pre><code> $('.order_table_item .variation dt').each(function () { if ($(this).text() == 'Candidate Name:') { $(this).next().show(); $(this).before("&lt;div class='count'&gt;&lt;/div&gt;"); $(this).next().after("&lt;div class='clear'&gt;&lt;/div&gt;"); } else { $(this).hide(); } }); $('.variation .count').each(function(i) { $(this).append((i+1)); }); </code></pre> <p><img src="https://i.stack.imgur.com/WgyRL.png" alt="enter image description here"></p> <p>I tried, </p> <pre><code>$('.order_table_item').each(function(i,e){ $('.variation .count').each(function(i) { $(this).append((i+1)); }); }); </code></pre> <p>and now its doubling up the numbers,</p> <p><img src="https://i.stack.imgur.com/lAcd1.png" alt="enter image description here"></p> <p>The cleaned up shorted down version of my html,</p> <pre><code> &lt;table class="shop_table order_details"&gt; &lt;tbody&gt; &lt;tr class="order_table_item"&gt; &lt;td class="product-name"&gt; &lt;dl class="variation"&gt; &lt;div class="count" style="border-top: 0px none;"&gt;11&lt;/div&gt; &lt;dd style="display: block; border-top: 0px none;"&gt;Dave&lt;/dd&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/dl&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="order_table_item"&gt; &lt;td class="product-name"&gt; &lt;dl class="variation"&gt; &lt;div class="count"&gt;22&lt;/div&gt; &lt;dd style="display: block;"&gt;JACK&lt;/dd&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;div class="count"&gt;33&lt;/div&gt; &lt;dd style="display: block;"&gt;JOHN&lt;/dd&gt; &lt;/dl&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
 

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