From the course: The DOM in JavaScript, jQuery, AngularJS, and React
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Select elements with getElementsByClassName
From the course: The DOM in JavaScript, jQuery, AngularJS, and React
Select elements with getElementsByClassName
- [Instructor] In this video, we're going to use JavaScript to interact the DOM. We'll be using one of the native methods, the getElementsByClassName and this method returns a collection of elements or objects which have all of the given class names and matching values. So in this exercise we're going to create two buttons. One will be showing the data or showing the names of all these team members, and so if you look at this list there's about six of them and then the names are contained within a paragraph tag that should have a matching class name, and then one of the button's will be showing the data or showing the names. The second button will be just to hide those data again. So let's head over back to Brackets and do the code. Here in Brackets I'm using this same file, the about file. Right about here, line 71, I'm going to just add a few lines here and I will be creating the first button. We're using the button tag. We're using a different approach in this example. I'll be…
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
-
-
-
-
Select elements with getElementById7m 26s
-
(Locked)
Select elements with getElementsByClassName9m 41s
-
(Locked)
Select groups of elements with getElementsByName8m 8s
-
(Locked)
Select elements with getElementsByTagName6m 15s
-
(Locked)
Add, append, and delete DOM nodes13m 43s
-
(Locked)
Updating content in place4m 16s
-
-
-
-
-