Skip to content

Instantly share code, notes, and snippets.

View firestar300's full-sized avatar

Milan Ricoul firestar300

View GitHub Profile
@firestar300
firestar300 / prevAll.js
Last active December 16, 2020 02:05
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
@firestar300
firestar300 / nextAll.js
Created January 15, 2019 08:50
nextAll method with Vanilla JS
export const nextAll = element => {
const nextElements = []
let nextElement = element
while(nextElement.nextElementSibling) {
nextElements.push(nextElement.nextElementSibling)
nextElement = nextElement.nextElementSibling
}
return nextElements