Created
March 22, 2017 20:58
-
-
Save dblodorn/66ca9226539c2c4ff52c15c5075bfbf1 to your computer and use it in GitHub Desktop.
Element Iterate Shell Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const elementIterate = (selector,fn) => { | |
| const itemToIterate = document.querySelectorAll(selector) | |
| let i = 0 | |
| setTimeout(() => { | |
| if(itemToIterate) { | |
| while(i < itemToIterate.length) { | |
| fn(itemToIterate,i) | |
| i++ | |
| } | |
| } | |
| }, 5) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {elementIterate} from './element-iterate' | |
| const functionToRepeat = (itemToIterate,i) => { | |
| console.log(itemToIterate[i] + [i]) | |
| } | |
| elementIterate('.some-selector', functionToRepeat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment