Created
May 9, 2018 15:48
-
-
Save paulrobertlloyd/d50e7728db960223d3e2b81c665a179d 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((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