document.addEventListener("DOMContentLoaded", function() {
// code
});
Two syntaxes can be used for this:
$( document ).ready(function() {
console.log( "ready!" );
});
Or the shorthand version:
$(function() {
console.log( "ready!" );
});
// A $( document ).ready() block.
$( document ).ready(function() {
console.log( "ready!" );
});
document.addEventListener("DOMContentLoaded", function(event) {
//we ready baby
});
window.onload = function() {
};
document.addEventListener("DOMContentLoaded", fn);
$(document).ready(function () {
//write your code here
});
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);
}
}