Reputation: 8272
How do I do the below with javascript?
$("div.details.counter span")
I can use ID's
but I'm curious how we can do the above jQuery style of getting stuff with pure javascript.
Upvotes: 0
Views: 31
Reputation: 27823
The solution with pure javascript for most selectors supported by jQuery is to use document.querySelectorAll:
document.querySelectorAll("div.details.counter span")
If you don't have support for querySelectorAll
in your browser of choice, you could take a look at jQuery's implementation of the selector engine to see how it matches various parts of the selector.
Upvotes: 2