Return to Snippet

Revision: 51056
at September 13, 2011 06:15 by cesarkohl


Updated Code
// Pure JavaScript
if(document.getElementById('example').length == 0){} // no element found

// jQuery
if($('element').length == 0){} // no element found

Revision: 51055
at September 13, 2011 06:11 by cesarkohl


Initial Code
// Pure JavaScript
if(document.getElementById('example').length == 0){}; // no element found

// jQuery
if($('element').length == 0;){} // no element found

Initial URL


Initial Description
How to know if an element exists in JS (and jQuery).

Initial Title
if exists in JS and jQuery

Initial Tags
javascript, jquery

Initial Language
JavaScript