Skip to content

Instantly share code, notes, and snippets.

@foo9
Last active December 16, 2015 02:09
Show Gist options
  • Select an option

  • Save foo9/5360249 to your computer and use it in GitHub Desktop.

Select an option

Save foo9/5360249 to your computer and use it in GitHub Desktop.
// how to use $("#hoge").visible(function () { console.log("(<●>д<●>)", this); }, function () { console.log("( ― д ― )", this); });
// uncompress
;(function ($) {
$.fn.visible = function (visible, invisible) {
if ((typeof visible !== "function") && (typeof invisible !== "function")) {
return this;
}
return this.each(function () {
if ($(this).css('display') === 'none') {
invisible.apply(this);
} else {
visible.apply(this);
}
});
};
})(jQuery || Zepto);
// compress
// ;(function(a){a.fn.visible=function(b,c){return"function"!==typeof b&&"function"!==typeof c?this:this.each(function(){"none"===a(this).css("display")?c.apply(this):b.apply(this)})}})(jQuery||Zepto);
@foo9
Copy link
Copy Markdown
Author

foo9 commented Apr 11, 2013

$("#hoge").visible(function(){

}).invisible(function(){

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment