How does jQuery's "document ready" function work? -


how jquery checking if document loaded? how checking document load finished?

check out function bindready in source code.

they bind domcontentloaded event (or onreadystatechange on browsers). have fallback regular load event, in case domcontentloaded isn't supported or not fired other reasons. on browsers supporting it, use call:

document.addeventlistener( "domcontentloaded", domcontentloaded, false ); 

on ie <9:

document.attachevent( "onreadystatechange", domcontentloaded); 

the second instance of domcontentloaded in these calls own function - reference ready function right above bindready in source code. function check dom tree done checking document.body. if doesn't exist yet, wait millisecond (using settimeout) , check again. when document.body exists, traverse list of callbacks you've set.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -