Skip to content

Instantly share code, notes, and snippets.

Created April 5, 2016 19:22
Embed
What would you like to do?
function addLinks () {
for (var i=0, link; i<5; i++) {
link = document.createElement("a");
link.innerHTML = "Link " + i;
link.onclick = function () {
alert(i);
};
document.body.appendChild(link);
}
}
// click vào 5 link đều ra số 5
window.onload = addLinks;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment