Created
April 3, 2022 04:27
-
-
Save xsbee/a2915a348f2f55d9b02a70b9c247606b to your computer and use it in GitHub Desktop.
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
function selectIfPreviousAll(base, previous) { | |
var matches = []; | |
document.querySelectorAll(base).forEach(function(e) { | |
var siblings = e.parentElement.childNodes; | |
if(siblings.length < 2) | |
return; | |
var eIndex = Array.prototype.indexOf.call(siblings, e); | |
matches.push(siblings[eIndex - 1]); | |
}); | |
return matches; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment