Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting direct children with "> .child" selector doesn't work #192

Open
guckstift opened this issue Feb 16, 2024 · 0 comments
Open

Selecting direct children with "> .child" selector doesn't work #192

guckstift opened this issue Feb 16, 2024 · 0 comments

Comments

@guckstift
Copy link

Xin Chao,

This doesn't work:

https://github.com/phuocng/frontend-tips/blob/main/contents/select-the-direct-children-of-an-element.mdx

Chrome says about it: "'> *' is not a valid selector."

But you can instead use the :scope CSS pseudo-class as the left side of ">" operator:

let parentElement = getElementById("parent");
parentElement.querySelectorAll(":scope > .foo");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant