Skip to content

Instantly share code, notes, and snippets.

@earlonrails
Last active December 23, 2017 18:24
Show Gist options
  • Save earlonrails/4172760 to your computer and use it in GitHub Desktop.
Save earlonrails/4172760 to your computer and use it in GitHub Desktop.
pure javascript version of jQuery's toggle. Now with show and hide! Yay!
HTMLElement.prototype.show = function(){
this.style.display = '';
}
HTMLElement.prototype.hide = function(){
this.style.display = 'none';
}
HTMLElement.prototype.toggle = function(){
if (this.style.display == 'none'){
this.show();
} else {
this.hide();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment