Skip to content

Instantly share code, notes, and snippets.

@seamusjr
Created October 25, 2011 22:11
Show Gist options
  • Save seamusjr/1314515 to your computer and use it in GitHub Desktop.
Save seamusjr/1314515 to your computer and use it in GitHub Desktop.
native js event handler example
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<!-- Date: 2011-10-25 -->
</head>
<body>
<button id="load-application">Load Application</button>
<script type="text/javascript">
var element = document.getElementById("load-application");
var loadApplication = function() {
console.log("Application loaded...");
};
var loadApplicationHandler = function() {
element.addEventListener("click", function() {
loadApplication();
}, false);
};
document.addEventListener("DOMContentLoaded", loadApplicationHandler, false);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment