So I've been trying to do the following bit of code without importing the jQuery library:
$(".parent-class").contents().find(".child-class").css("color", "red");
I know that .contents() gets the children of each element in the set of matched elements including text and comment nodes, from the jQuery docs, but I don't think I understand what that description means. I've tried getting the children of .parent-class
with:
let theChildren = document.querySelector('.parent-class').children;
but this doesn't do the same thing as .contents().find(".child-class")
does.
EDIT: As requested in the comments I've made a new question as this one seems to not be specific enough.
See Question&Answers more detail:os