Wilson Wilson - 1 year ago 150
Javascript Question

Check if a div does NOT exist with javascript

Checking if a div exists is fairly simple



But how can I check if a div with the given id does not exist?

Answer Source
var myElem = document.getElementById('myElementId');
if (myElem === null) alert('does not exist!');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download