-
-
Save atelierbram/0bb1bd7aa9b4296d9ece618ddeec6bd7 to your computer and use it in GitHub Desktop.
Andy Dennis’ function introduction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<a class="that" href="yippee.html">That link</a> | |
<script> | |
var foo = function () { | |
var $ = document.querySelector.bind(document) | |
var el = { | |
thatLink: $('a.that') | |
} | |
function addListeners () { | |
el.thatLink.addEventListener('click', function (e) { | |
e.preventDefault() | |
simpleHandler(e.target) | |
}, false) | |
} | |
function init () { | |
addListeners() | |
} | |
function simpleHandler (link) { | |
console.log(link.href) | |
} | |
return { | |
init: init | |
} | |
}() | |
foo.init() | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment