Created
May 18, 2010 19:05
-
-
Save webdood/405381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////////////////////////// | |
// | |
// showOrHide([object|string] oHTMLElement, boolean bShowOrHide) | |
// Shows or Hides an HTMLElement. | |
// You can pass in the id to an object or the actual object | |
// | |
//////////////////////////////////////////////////////////////////////////////// | |
function showOrHide(oHTMLElement, bShowOrHide) { | |
try { | |
if (typeof(oHTMLElement)=="string") { | |
oHTMLElement = document.getElementById(oHTMLElement); | |
} | |
if (oHTMLElement && oHTMLElement.style) { | |
if (bShowOrHide == 'inherit') { | |
oHTMLElement.style.visibility = 'inherit'; | |
} else { | |
if (bShowOrHide) { | |
if (oHTMLElement.nodeName == 'TR') { | |
oHTMLElement.style.visibility = 'inline-table'; | |
} else { | |
oHTMLElement.style.visibility = 'visible'; | |
} | |
} else { | |
oHTMLElement.style.visibility = 'hidden'; | |
} | |
try { | |
if (bShowOrHide) { | |
oHTMLElement.style.display = 'block'; | |
} else { | |
oHTMLElement.style.display = 'none'; | |
} | |
} | |
catch (ex) { | |
} | |
} | |
} | |
} | |
catch (ex) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
showOrHide algorithm
Making it easier for me to look up my own most useful block of code for displaying/hiding elements. This is the same bit of code I wrote for Microsoft that shipped with Vista and now Windows 7 with the Sidebar gadgets.