Created
November 26, 2012 14:16
-
-
Save avi-flombaum/4148429 to your computer and use it in GitHub Desktop.
jQuery.exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calls function on $ if it is an existing piece of dom. | |
// $('foo.bar').exists(function(){$("#target").show();}) -> foo.bar will appear where foo.bar is present | |
// $('foo.baz').exists(function(){$("#target").show();}) -> foo.baz will not appear where foo.baz is not present | |
jQuery.fn.exists = function(func){if (this[0]) {if (func){func.apply(this, arguments);} else {return true;}} else {if (func){return this;} else {return false;}};}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment