/ Published in: JavaScript
How to know if an element exists in JS (and jQuery).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Pure JavaScript if(document.getElementById('example').length == 0){} // no element found // jQuery if($('element').length == 0){} // no element found