Answers for "jQuery Dom ready equivalent in pure JavaScript"

0

jQuery Dom ready equivalent in pure JavaScript

docReady(function() {
    // DOM is loaded and ready for manipulation here
});
Posted by: Guest on April-28-2021
0

jQuery Dom ready equivalent in pure JavaScript

function docReady(fn) {
    // see if DOM is already available
    if (document.readyState === "complete" || document.readyState === "interactive") {
        // call on next available tick
        setTimeout(fn, 1);
    } else {
        document.addEventListener("DOMContentLoaded", fn);
    }
}
Posted by: Guest on April-28-2021

Code answers related to "jQuery Dom ready equivalent in pure JavaScript"

Browse Popular Code Answers by Language