Skip to content

Instantly share code, notes, and snippets.

@chiehmin
Created September 2, 2012 11:56
Show Gist options
  • Save chiehmin/3597654 to your computer and use it in GitHub Desktop.
Save chiehmin/3597654 to your computer and use it in GitHub Desktop.
Javascript Practices
<html>
<head>
<title>Reveal</title>
<style type="text/css">
.reveal * { display: none; }
.reveal .handle { display: block; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('.handle').click(function(){
var box = $(this).parent();
if(box.hasClass('reveal'))
box.removeClass('reveal').addClass('revealed');
else
box.removeClass('revealed').addClass('reveal');
});
});
</script>
</head>
<body>
<div class="reveal">
<h1 class="handle">Click Here to Reveal Hidden Text</h1>
<p> haha </p>
</div>
<div class="reveal">
<h1 class="handle">Click Here to Reveal More</h1>
<p> more </p>
</div>
</body>
</html>
<html>
<head>
<title>Show Time</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
function showTime()
{
var date = new Date();
var str = date.toLocaleTimeString();
$('#time_box').text(str);
}
$(function(){
setInterval(function(){showTime()}, 1000);
});
</script>
</head>
<body>
<div id="time_box"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment