Jquery tr confusion selection
I started working with jQuery again after a few months and got a little confused. I went to news.ycombinator.com , went to console in chrome and typed $('tr')
to get an array of strings, but it only returned the first row (although the first table has 3 rows).
When I type var x = $('tr:odd')
chrome in the console, I get the error
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': 'tr:odd' is not a valid selector.
Am I missing something obvious?
+3
source to share
1 answer
Want an array of all tr ββtags?
The site does not use jQuery. Try it with regular Javascript in your console:
document.getElementsByTagName("tr")
This will return an array with all tags that exist in the DOM.
To use "$" to select elements, the site must load jQuery in the header.
Now, what do you want to do with this choice?
+1
source to share