Skip to content

Instantly share code, notes, and snippets.

Created January 4, 2012 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1560533 to your computer and use it in GitHub Desktop.
Save anonymous/1560533 to your computer and use it in GitHub Desktop.
CSS Style - Should set to empty string, not inherit. Just an example
<html>
<head>
<style type="text/css">
.test1 {
display: inline;
border: 2px solid green;
background-color: tan;
}
.test2 {
display: block;
border: 2px solid red;
background-color: navy;
}
</style>
<script type="text/javascript">
var b = 0;
var a = 0;
function reset(){
a=0;
b=0;
document.getElementById('hi').style.display="";
}
function usingBlank(){
var x = document.getElementById('hi');
if (a === 0) {
x.style.display = "none";
a = 1;
} else {
x.style.display = "";
a = 0;
}
}
function usingInherit(){
var x = document.getElementById('hi');
if(b===0){
x.style.display="none";
b=1;
} else {
x.style.display="inherit";
b= 0;
}
}
</script>
</head>
<div class="test1">
<div class="test2" id="hi">
Hello
</div>
</div>
<button onclick="usingInherit()">Click For Inherit</button>
<button onclick="usingBlank()">Click For Empty String</button>
<button onclick="reset()">Click To Reset</button>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment