Created
April 25, 2011 17:51
-
-
Save resba/940888 to your computer and use it in GitHub Desktop.
hideDiv Javascript Function
This file contains hidden or 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
// hideDiv Function v1.5 by Matthew Sowden. Based off the Middle Bucks Institute of Technology Online Yearbook Student Content Check Script, Originally Designed by Matthew Sowden. | |
// Author: Matthew Sowden ([email protected]) | |
// Website: www.resbah.com | |
// Disclaimer: This code is provided on an AS-IS basis and does NOT offer any support. | |
// License: You are free to use this code in any project or modify it in any way, so long as the credit is given. | |
function hideDiv(div,datacheck){ | |
if (document.getElementById(datacheck).innerHTML == '') //Statement checks to see if datacheck contains any text between the opening and closing tag. | |
{ | |
document.getElementById(div).innerHTML = ''; //If the above statement is TRUE, this ID-defined element has its content set to nothing. | |
} | |
} |
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>hideDiv Script Example</title> | |
<!-- Link to script --> | |
<script src="hideDiv.js" type="text/javascript"></script> | |
</head> | |
<body onload="hideDiv('checked','data'); hideDiv('checked2','data2');"> | |
<div id="checked"> | |
Since there is no data in the span below, this division will be hidden and this text will never be shown. | |
<span id="data"></span> | |
</div> | |
<div id="checked2"> | |
There is content here. | |
<span id="data2">since there is content in here, this div will remain visible</span> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment