Skip to content

Instantly share code, notes, and snippets.

@pilgreen
Created January 22, 2020 17:43
Show Gist options
  • Save pilgreen/44dbe786f51ad3c552f1228187b35c83 to your computer and use it in GitHub Desktop.
Save pilgreen/44dbe786f51ad3c552f1228187b35c83 to your computer and use it in GitHub Desktop.
Gets elements between specific tags
function nextUntil(elem, selector) {
let siblings = [];
elem = elem.nextElementSibling;
while(elem) {
if(elem.matches(selector)) break;
siblings.push(elem);
elem = elem.nextElementSibling;
}
return siblings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment