Author: Not specified Language: javascript
Description: Not specified Timestamp: 2017-08-01 10:28:21 +0000
View raw paste Reply
  1. for (var i = 0; i < 5; i++) {
  2.   var btn = document.createElement('button');
  3.   btn.appendChild(document.createTextNode('Button ' + i));
  4.   btn.addEventListener('click', function(){ console.log(i); });
  5.   document.body.appendChild(btn);
  6. }
View raw paste Reply