JavaScript JavaScript and the DOM Getting a Handle on the DOM DOM Selection - More Review

Ken Okiebisu
Ken Okiebisu
9,613 Points

document.querySelectorAll on classes(Question from quiz)

The question asked my how I would assign all elements with the class ‘student-info’ into the constant studentInfo using the querySelectorAll method. I wrote it as the following:

const studentInfo= document.querySelectorAll(‘.student-info’);

I keey getting it wrong and I don’t know why. I would like to know what is wrong with my code. Thanks.

2 Answers

Emmanuel C
Emmanuel C
6,869 Points

After trial and error of copy and pasting your code, when I use double quotes instead of single quotes, it works. There isnt a big difference between the two, at least in javascript, so your code is correct and I wouldn't worry about it to much.

Ken Okiebisu
Ken Okiebisu
9,613 Points

Thanks for the solution. It helps.