I have this:
I'm trying to load this js code, value.id corresponds to an element that is detected after loading page. But actually this code is running before the element is loaded and im having this error:
Cannot read property 'nodeType' of null
I want to add something like delay on the document.getElementById(value.id)
I tried this, but nothing:
const area = setTimeout(document.getElementById(value.id), 4000);
Count.on(area, counter => {
...
and:
function setDelay() {
document.getElementById(value.id);
}
setTimeout(setDelay, 4000);
const area = setDelay
Count.on(area, counter => {
...
both giving same error, any idea??
Thanks to all, i solved it with this:
$(document).ready(function(){
// your code
});