I am implementing a tree browser in HTML. On clicking a node, I call a function that adds the node's child elements. So far so good. I now want to immediately invoke the click handler of one of the child elements to expand that too. My problem is that jQuery can't find the child elements that have just been added. When I step through in the debugger, my code to find the elements is being invoked before the new elements get rendered by the browser, which I'm guessing is the problem.
Is there some event I can wait for (similar to onload maybe) that marks when the newly added HTML is visible? Or a method I can call to force the rendering to take place earlier? Any suggestions would be welcome.
Note: I have since realised that the problem was entirely my fault, not the browser's or jQuery's. Please see my answer below.