Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. var animals = ["aligator", "bat", "cow"];
  2. var good = document.getElementById("good");
  3. for (var i = 0; i < animals.length; i++) {
  4. var animal = animals[i];
  5. var input = document.createElement("input");
  6. input.type = "button";
  7. input.value = animal;
  8. input.style.marginLeft = "5px";
  9. input.onclick = (function(animal) {return function() {alert(animal);};})(animal);
  10. good.appendChild(input);
  11. }
Add Comment
Please, Sign In to add comment