If I use the $(document).ready()
handler from within a function, will it still guarantee that the code inside it will only be run if the document is ready, even if the document ready event has occurred well in the past?
Yes.
From the jQuery ready
function source.
// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
return setTimeout( jQuery.ready, 1 );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With