Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var animals = ["aligator", "bat", "cow"];
- var good = document.getElementById("good");
- for (var i = 0; i < animals.length; i++) {
- var animal = animals[i];
- var input = document.createElement("input");
- input.type = "button";
- input.value = animal;
- input.style.marginLeft = "5px";
- input.onclick = (function(animal) {return function() {alert(animal);};})(animal);
- good.appendChild(input);
- }
Add Comment
Please, Sign In to add comment