Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. // Nodelist forEach polyfill
  2. if (window.NodeList && !NodeList.prototype.forEach) {
  3. NodeList.prototype.forEach = function (callback, thisArg) {
  4. thisArg = thisArg || window;
  5. for (var i = 0; i < this.length; i++) {
  6. callback.call(thisArg, this[i], i, this);
  7. }
  8. };
  9. }
  10.  
  11. // IEでも使える
  12. document.querySelectorAll('selector').forEach(function(element) {
  13. element.addEventListener('click', function() { /* */});
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement