Skip to content

Instantly share code, notes, and snippets.

@firestar300
Last active December 16, 2020 02:05
Show Gist options
  • Save firestar300/28983857872182521f9842f2ddb9c0eb to your computer and use it in GitHub Desktop.
Save firestar300/28983857872182521f9842f2ddb9c0eb to your computer and use it in GitHub Desktop.
prevAll method with Vanilla JS
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