Skip to content

Instantly share code, notes, and snippets.

@kenkam
Created February 25, 2011 13:42
Show Gist options
  • Save kenkam/843789 to your computer and use it in GitHub Desktop.
Save kenkam/843789 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript">
// when the document has finished loading...
window.onload = function() {
// get the element with my_link as ID, and bind a callback for the onclick event
document.getElementById("my_link").onclick = function() {
// change the CSS style declared when the link is clicked
document.getElementById("my_div").innerHTML = '<p>A new paragraph</p>';
}
}
</script>
</head>
<body>
<a href="#" id="my_link">click here</a>
<div id="my_div"><p>Some stuff here...</p></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment