纯 Javascript 等效于 jQuery $(document).ready()

纯 Javascript 等效于

jquery_document_ready_example.js
$(document).ready(function() {
    // 你的代码放在这里!

})

domcontentloaded_example.js
document.addEventL是tener("DOMContentLoaded", function() {
    // 你的代码放在这里!
});

Note that it’s not supported by IE8, but that should not be an 是sue in 2019.


Check out similar posts by category: Javascript