Skip to content

Instantly share code, notes, and snippets.

@thetekst
Created March 12, 2013 09:03
Show Gist options
  • Save thetekst/5141317 to your computer and use it in GitHub Desktop.
Save thetekst/5141317 to your computer and use it in GitHub Desktop.
jQuery function exists HTML-element
// write jQuery function
jQuery.fn.exists = function() {
return $(this).length;
}
// use the function
// if not exists run the getPreloader()
if(!$("#loader").exists()){
getPreloader();
}
// if exists remove tag
if($("#loader").exists()){
jQuery("#loader").remove()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment