Skip to content

Instantly share code, notes, and snippets.

@julesbou
Last active May 13, 2016 18:19
Show Gist options
  • Save julesbou/7046d4b726155c496f92c39906be9484 to your computer and use it in GitHub Desktop.
Save julesbou/7046d4b726155c496f92c39906be9484 to your computer and use it in GitHub Desktop.
HTMLElement.prototype.show = function() {
this.style.display = ''
}
HTMLElement.prototype.hide = function() {
this.style.display = 'none'
}
HTMLElement.prototype.toggle = function(bool) {
this.style.display = bool ? '' : 'none'
}
HTMLElement.prototype.visible = function() {
return this.style.display !== 'none'
}
// usage: $('.foo').hide()
// usage: $('.foo').show()
// usage: $('.foo').toggle(false) // hide
// usage: $('.foo').visible() // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment