Last active
August 29, 2015 13:58
-
-
Save allanharris/10059002 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script> | |
</head> | |
<body> | |
<h1>Here is our 5 amazing Links!</h1> | |
<a id="link1" href="#">1</a> | |
<a id="link2" href="#">2</a> | |
<a id="link3" href="#">3</a> | |
<a id="link4" href="#">4</a> | |
<a id="link5" href="#">5</a> | |
<script type="text/javascript"> | |
function init() { | |
this.numberOfLinks = 5; | |
for (var i = 0; i <= this.numberOfLinks; ++i) { | |
if ($('#link' + i).text() === 2) { | |
$('#link' + i).text('Link number 2'); | |
} | |
$('#link' + i).click(function () { | |
alert("Link " + i + " of " + this.numberOfLinks + " clicked!"); | |
}); | |
} | |
return | |
this.numberOfLinks; | |
} | |
var count = init(); | |
console.log('Number of links: ', count); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment