Skip to content

Instantly share code, notes, and snippets.

@bjartek
Created July 17, 2009 21:24
Show Gist options
  • Save bjartek/149285 to your computer and use it in GitHub Desktop.
Save bjartek/149285 to your computer and use it in GitHub Desktop.
<html>
<body>
<a href="rat">rat</a>
<a href="donkey">doneky</a>
<script type="text/javascript">
var anchors = document.getElementsByTagName("a");
console.log("foobar");
for(var i = 0; i < anchors.length; i++) {
var a = anchors[i];
a.onclick = function(el) {
alert(this.getAttribute("href"));
return false;
};
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment