babyboomer Posted October 2, 2018 Share Posted October 2, 2018 According to my research, all indications are that the getElementByClassName method can accept multiple arguments. for example: var x = document.getElementsByClassName("class1 class2"); I haven't gotten this to work. I have been experimenting with it on CodePen. What am I missing? Link to comment Share on other sites More sharing options...
Ingolme Posted October 2, 2018 Share Posted October 2, 2018 That's not how getElementsByClassName works. Putting both class names there will only give you elements that have both of the values in their class attribute. If you want to search for elements that contain either one of the classes. then you have to call getElementsByClassName twice. Link to comment Share on other sites More sharing options...
babyboomer Posted October 2, 2018 Author Share Posted October 2, 2018 Ah, okay. That makes sense. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now