Created
January 22, 2020 17:43
-
-
Save pilgreen/44dbe786f51ad3c552f1228187b35c83 to your computer and use it in GitHub Desktop.
Gets elements between specific tags
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
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