Skip to content

Instantly share code, notes, and snippets.

@paulrobertlloyd
Created May 9, 2018 15:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paulrobertlloyd/d50e7728db960223d3e2b81c665a179d to your computer and use it in GitHub Desktop.
Save paulrobertlloyd/d50e7728db960223d3e2b81c665a179d to your computer and use it in GitHub Desktop.
Andy Dennis’ function introduction
<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((link: http://e.target) 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