Advertisement
nucklear

Execute only if selector exists Jquery

May 30th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($) {
  2.   $(function() { //on DOM ready
  3.  
  4. jQuery.fn.exists = function(){return this.length>0;}
  5.  
  6.  if ($("SELECTOR").exists()) {
  7.  
  8. blah, blah, blah!
  9.  
  10. }
  11.  
  12. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement