From the course: JavaScript: Enhancing the DOM (2013)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Isolating elements by class name
From the course: JavaScript: Enhancing the DOM (2013)
Isolating elements by class name
So far, we've looked at picking elements by ID and tag name. So, you're probably thinking that you can also pick elements by class name, and you would be right, sort of. The getElementsByClassName function is a bit of a new addition. Of course, it does that you select that elements with a specific class, but because it is a newer selector it is incompatible with older browsers. Whenever you have a question about whether a browser has support for a method, you should check out a couple of web pages. This one right here called caniuse.com is a really good resource. So, if you scroll down you can see that this method has support in pretty much every modern browser but not older versions of IE. Another page you should check out is the W3C.ompatibilty. If you scroll down on this page see you can get to the same information on the get element by class name method. Now, I'm using a pretty modern browser here this is a late version of Chrome so you shouldn't have a problem with this method…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Selecting elements with getElementById4m 10s
-
(Locked)
Choosing elements by HTML tag3m 20s
-
(Locked)
Isolating elements by class name3m 12s
-
(Locked)
Querying CSS to select elements4m 54s
-
(Locked)
Working with named form elements3m 39s
-
(Locked)
Understanding nodeType, nodeName, and nodeValue4m 30s
-
(Locked)
Traversing up and down DOM nodes4m 40s
-
(Locked)
Targeting node elements2m 44s
-
(Locked)
-
-
-
-