Timing issue with jQuery and $(document).ready()

Posted by ripper234 on Stack Overflow See other posts from Stack Overflow or by ripper234
Published on 2010-04-27T18:11:22Z Indexed on 2010/04/27 18:13 UTC
Read the original article Hit count: 105

Filed under:
|

I have the following code block code when the document is ready:

$(document).ready(function() {
    createDivs(); // creates some divs with class 'foo';

    // iterate
    $(".foo").each(function(index) {
        alert(index + " - " + $(this).text());
    });
}

I find that the "iterate" part misses the divs I created in the createDivs() method entirely! Is there some timing issue I'm not aware of? Why doesn't jquery see the divs that were just created?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript