Checking if a div exists is fairly simple
if(document.getif(document.getElementById(\'if\')){ }
But how can I check if a div with the give
There's an even better solution. You don't even need to check if the element returns null. You can simply do this:
null
if (document.getElementById('elementId')) { console.log('exists') }
That code will only log exists to console if the element actually exists in the DOM.
exists