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

Select elements with getElementsByClassName

From the course: The DOM in JavaScript, jQuery, AngularJS, and React

Start my 1-month free trial

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…

Contents