In addition to the custom hacks, in recent browsers you can use the native methods defined in the W3C Selectors API Level 1, namely document.querySelector()
and document.querySelectorAll()
:
var cells = document.querySelectorAll("#score > tbody > tr > td:nth-of-type(2)");
More Related Contents:
- Changing CSS pseudo-element styles via JavaScript [duplicate]
- Can I have an element with an ID that starts with a number?
- Using querySelector with IDs that are numbers
- Good ways to improve jQuery selector performance?
- Using querySelectorAll to retrieve direct children
- How to get nth-child selector to skip hidden divs [duplicate]
- How to select nth line of text (CSS/JS)
- Get unique selector of element in Jquery
- How to select all checkboxes with jQuery?
- Get element’s CSS selector (when it doesn’t have an id)
- Test if a selector matches a given element
- Get the DOM path of the clicked
- jQuery vs document.querySelectorAll
- Get CSS path from Dom element
- How to get the second match with QuerySelector?
- querySelector search immediate children [duplicate]
- CSS selector for targeting only immediate children and not other identical descendants
- Why does document.querySelectorAll return a StaticNodeList rather than a real Array?
- How to generate unique css selector for DOM element?
- How to use querySelectorAll only for elements that have a specific attribute set?
- Are data attribute css selectors faster than class selectors?
- QuerySelector for Web Elements Inside iframe
- How to create a collapsing tree table in html/css/js?
- Using querySelectorAll(). Is the result returned by the method ordered?
- Can I use an attribute selector for CONTAINS in queryselector()?
- CSS: Select element only if a later sibling exists
- iOS8 Safari after a pushState the :nth-child() selectors not works
- How to do a wildcard element name match with “querySelector()” or “querySelectorAll()” in JavaScript?
- “querySelectorAll()” with multiple conditions in JavaScript
- How to use a regular expression in querySelectorAll?