Download
Edit

Check if an element exists

VanaryonVanaryon
Valérian Saliou
Added on 2010-05-24 19:39:14

 

Check if an element exists - Show - Edit - Download

 

0 1 2 3 4 5 6 7 8 9 10 11
/* REQUIRES JQUERY */
 
// The function
$.exists = function(selector) {
        return ($(selector).length > 0);
}
 
// We check an element
if($.exists('#onediv'))
  alert('Exist!');
else
  alert('Don\'t exist!');