“JQuery Dom Ready Equivalent in Pure JavaScript” Kode Jawaban

JQuery Dom Ready Equivalent in Pure JavaScript

docReady(function() {
    // DOM is loaded and ready for manipulation here
});
code fighter

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);
    }
}    
code fighter

Jawaban yang mirip dengan “JQuery Dom Ready Equivalent in Pure JavaScript”

Pertanyaan yang mirip dengan “JQuery Dom Ready Equivalent in Pure JavaScript”

Lebih banyak jawaban terkait untuk “JQuery Dom Ready Equivalent in Pure JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya