I have a jQuery script that scans a list of divs and then its children and outputs:
- Item title
- Product description
I notice that although the two console.log()
are next to each other in the inner $.each()
, I expect to see:
Title 1 Description 1 Title 2 Description 2 Title 3 Description 3 ... etc.
Instead, I see:
Title 1 Title 2 Title 3 ... etc.
Description 1 Description 2 Description 3 ... etc.
Updated internal .find()
s:
script:
$('.ghx-backlog').each(function(){ $($(this).find('div[class*=has-issues]')).each(function(index){ console.log($(this).find('.ghx-key > a').text());
Markup:
<div id="ghx-backlog" class="ghx-backlog" data-rendered="123456789"> <div class="ghx-issues js-issue-list ghx-has-issues"> <div class="js-issue js-sortable js-parent-drag ghx-issue-compact ghx-type-6" data-issue-id="1233456" data-issue-key="Title 1"> <div class="ghx-issue-content"> <div class="ghx-row"> <div class="ghx-key"> <a href="/browse/Title 1" title="Title 1" class="js-key-link">XXXXXX-##</a> </div> <div class="ghx-summary" title="Description 1"> <span class="ghx-inner">Description 1</span> </div> </div> <div class="ghx-row"> <div class="ghx-key"> <a href="/browse/Title 2" title="Title 2" class="js-key-link">XXXXXX-##</a> </div> <div class="ghx-summary" title="Description 2"> <span class="ghx-inner">Description 2</span> </div> </div> </div> </div> </div> </div>
source share