What\'s the native equivalent of jQuery\'s $.fn.has?
For example, how would you write the following code:
$(\"li\").has(\"ul\").css(\"background-color\",
I know this is an extremely late answer but here is an updated version of Lennholm's answer.
const has = (selector, sub) => {
const matches = Array.from(document.querySelectorAll(selector));
return matches.filter(match => match.querySelector(sub) !== null);
};
has("li", "ul").forEach(li => {
li.style["background-color"] = "red";
});