Querying CSS to select elements


show more Querying CSS to select elements provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Enhancing the DOM show less
please wait ...

Querying CSS to select elements

Selecting elements can be a little bit of a pain with JavaScript. You can select things by ID, tag name, and on newer browsers, by class name. If you're familiar with CSS, one of the best ways of isolating elements is by using a newer function called querySelector. querySelector and its cousin, querySelectorAll let's you choose elements by using CSS-like notation. This let's you pick nodes through CSS selectors. That's super similar to the way that jQuery works. So, if you're familiar selecting things with jQuery, you'll be right at home with this.

Now, this is not compatible with older browsers. But it does have a little bit better support than get elements by class name. Notice that it's supported by IE8. This is super easy to use, and probably the best way to select elements in HTML. So, I'm going to go to this HTML document and pull up the developer tools. So, I'm hitting Cmd+Option+I, that's Ctrl+Alt+I on a PC, then hitting the E...

Querying CSS to select elements
Video duration: 4m 54s 2h 3m Intermediate

Viewers:

Querying CSS to select elements provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Enhancing the DOM

Subjects:
Developer Web
Software:
HTML JavaScript
Author:
please wait ...