Comments (5)
You need to use :scope
, as described on this Mozdev article: https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll
No support for IE, though.
from youmightnotneedjquery.
I may not be understanding what you're referring to, but you can call querySelectorAll
on any DOM node to get matches inside it:
someElement.querySelectorAll('.cats');
from youmightnotneedjquery.
I know! Check out the jsfiddle...
Edit: my bad.. forgot to include jquery link in the fiddle.
from youmightnotneedjquery.
For anyone else that stumbles into this, here is a decent summary (visit some of the links/fiddles too) of the pros/cons of jquery
vs querySelectorAll
.
The biggest issue that sticks out to me (assuming it hasn't been elsewhere addressed in the past 5+ years) is how someElement.querySelectorAll('.element-outside-someElement .cats');
returns different results than jQuery(someElement).find('.element-outside-someElement .cats');
from youmightnotneedjquery.
DOMElement.querySelectorAll
doesn't behave like $Element.find
.
Here are some links discussing the issue:
http://ejohn.org/blog/thoughts-on-queryselectorall/
https://www.lvh.io/posts/queryselectorall-from-an-element-probably-doesnt-do-what-you-think-it-does.html
from youmightnotneedjquery.
Related Issues (20)
- Range labels should be clickable for accessibility
- Two comparison directories HOT 1
- Errors when loading in Internet Explorer 11 HOT 2
- Modernization HOT 17
- Replace slider with radio buttons or select HOT 9
- Bugs with Brazilian/Portuguese internationalization HOT 1
- Don't change URL query params by default HOT 1
- Support adding HTML for a defer/module load example
- I18n HOT 3
- Support for refresh an element HOT 3
- Namespaced Events
- Event delegation does not match jQuery behaviour HOT 3
- The selector option of Prev does not match jQuery behaviour
- Spread operator is not needed for the iterable in for...of
- Last is having a NodeList uses array method directly
- Trigger Native needs to be looked into HOT 2
- Next is missing the feature of optional selector, which the jQuery version has HOT 1
- The `:visible` selector is not listed HOT 1
- Example with error HOT 1
- Some example, why not jquery for readibility ? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from youmightnotneedjquery.