I was a bit disappointed with jQuery in the demo I spank together, and I was wondering if the following restriction is only for jQuery selector and search methods, or am I just using it incorrectly.
Here is an example HTML block:
<div class='div_item'> <td class='list'> <dl><dt class="access_text">Div1 text1</dt></dl> <dl><dt class="access_text">Div1 text2</dt></dl> <dl><dt class="access_text">Div1 text3</dt></dl> </td> </div> <div class='div_item'> <td class='list'> <dl><dt class="access_text">Div2 text1</dt></dl> <dl><dt class="access_text">Div2 text2</dt></dl> <dl><dt class="access_text">Div2 text3</dt></dl> </td> </div>
Here's the jQuery 1.9.2 script:
$().ready(function(){ $('.div_item'); // this is a 2 jQuery array, with no children $('.div_item').find('.access_text'); // This is empty, length 0, .div_item children aren't populated. Like I was using .children() $('.div_item').find('.access_text').each(function() { // This doesn't work because the .div_item children aren't populated? alert($(this).innerText); }): });
My question is: is there a reason why children in $('.div_item') array objects are not populated? If they are not filled in, they cannot be referenced, therefore .find() 'ed cannot be for the correct one. This is where I think my problem is the problem.
All the suggestions I've seen so far work for a more dense DOM. for example, <div class='div_item'><dt class="access_text"></dt></div> , but not for what is further nested.
source share