GithubHelp home page GithubHelp logo

Comments (5)

The4thLaw avatar The4thLaw commented on July 28, 2024 2

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.

zackbloom avatar zackbloom commented on July 28, 2024

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.

agamemnus avatar agamemnus commented on July 28, 2024

I know! Check out the jsfiddle...

Edit: my bad.. forgot to include jquery link in the fiddle.

from youmightnotneedjquery.

timmfin avatar timmfin commented on July 28, 2024

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.

varemenos avatar varemenos commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.