Can I use elements loaded into the DOM with html() immediately?
For example:
$('#mydiv').html('<div><p><span id="innerElement"></span></p></div>');
$('#innerElement').css('color','red');
This is a trivial example which I'm sure would work - but if the html being loaded is complex - a large html fragment with many elements - the question is are the elements immediately available to the jQuery selector and DOM operations? I would have thought not - as the elements have to be added to the DOM and that can take a lot more time than just executing code.
This seems an important question about how jQuery works which I assume will also relate to append, preprend etc. I'm surprised I can't see it covered in the documentation for html().
Thanks
Justin