Skip to content

Instantly share code, notes, and snippets.

@Kasahs
Last active August 29, 2015 14:08
Show Gist options
  • Save Kasahs/0da808d7c6ef9e5f7eaa to your computer and use it in GitHub Desktop.
Save Kasahs/0da808d7c6ef9e5f7eaa to your computer and use it in GitHub Desktop.
Toggle visibility of an element. Chainable.
Element.prototype.toggleVisibility = function () {
this.style.visibility = (this.style.visibility == '' || this.style.visibility == 'visible') ? 'hidden' : 'visible';
return this;
}
@Kasahs
Copy link
Author

Kasahs commented Nov 2, 2014

Usage:

var el = document.getElementById('myElement');
el.toggleVisibility();

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