3 ms·
You can also do this with DOM APIs, no? https://developer.mozilla.org/en-US/docs/Web/API/Element/closest https://developer.mozilla.org/en-US/docs/Web/API/Eleme
by frosted-flakes 4y ago
You can also do this with DOM APIs, no?
https://developer.mozilla.org/en-US/docs/Web/API/Element/closest https://developer.mozilla.org/en-US/docs/Web/API/Element/clo...
- augusto-moura 4y agoIs not the same thing as it is a Element method, not NodeList one, so you will would need to map it instead. Because NodeList doesn't have the .map method you would also need to transform it to a Array first. So the actually drop-in replacement of `$(foo).closest(bar)` would be something like: Array.from(document.querySelector(foo)).map(el => el.closest(bar))
- mejutoco 4y agoThis did not exist the last time I looked. TIL. Thank you!