Skip to content

Instantly share code, notes, and snippets.

@kogcyc
Created October 10, 2013 00:22
Show Gist options
  • Save kogcyc/6910945 to your computer and use it in GitHub Desktop.
Save kogcyc/6910945 to your computer and use it in GitHub Desktop.
How the CSS display: none/block attribute works
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
body {
margin: auto;
}
#one {
width: 200px;
padding: 10px;
background-color: #99f;
}
#two {
width: 200px;
padding: 10px;
background-color: #9f9;
}
#three {
width: 200px;
padding: 10px;
background-color: #f99;
}
</style>
<script type='text/javascript'>
$( document ).ready(function() {
$("#one").click(function() {
$("#two").css('display', 'none');
});
$("#three").click(function() {
$("#two").css('display', 'block');
});
});
</script>
<body>
<div id="one">One</div>
<div id="two">Two</div>
<div id="three">Three</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment