Skip to content

Instantly share code, notes, and snippets.

@scott-joe
Last active December 19, 2015 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scott-joe/5960666 to your computer and use it in GitHub Desktop.
Save scott-joe/5960666 to your computer and use it in GitHub Desktop.
Works like .hide and .show but maintains element height. Based on http://jsfiddle.net/nGhjQ/
(function($) {
$.fn.invisible = function() {
return this.each(function() {
$(this).fadeTo(100, 0);
$(this).css("visibility", "hidden");
});
};
$.fn.visible = function() {
return this.each(function() {
$(this).css("visibility", "visible");
$(this).fadeTo(100, 1);
});
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment