Last active
December 16, 2020 02:05
-
-
Save firestar300/28983857872182521f9842f2ddb9c0eb to your computer and use it in GitHub Desktop.
prevAll method with Vanilla JS
This file contains 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 prevAll = element => { | |
const prevElements = [] | |
let prevElement = element.parentNode.firstElementChild | |
while(prevElement !== element) { | |
prevElements.push(prevElement) | |
prevElement = prevElement.nextElementSibling | |
} | |
return prevElements | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment