Skip to content

Instantly share code, notes, and snippets.

@AndrewStanton94
Created December 19, 2014 17:32
Show Gist options
  • Save AndrewStanton94/832e0daa6360578eb206 to your computer and use it in GitHub Desktop.
Save AndrewStanton94/832e0daa6360578eb206 to your computer and use it in GitHub Desktop.
Use to hide or show an element. Requires button to toggle, element to hide and label for button.
function flipHSpara(btn, para, label)
{
var button = document.getElementById(btn);
var parastyle = document.getElementById(para).style;
label = label || ''; //http://javascript.info/tutorial/arguments
if (parastyle.display==='none')
{parastyle.display='block'; button.value='Hide ' + label ;}
else
{
parastyle.display='none'; button.value='Show ' + label;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment