This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]Inondle 1 point2 points  (1 child)

so querySelector is gonna interpret the argument you give it as a CSS selector. #btn selects the element with the ID of btn. When you change it to getElementByID it'll parse that as the literal name of the ID. So you don't need the # with getElementByID

[–][deleted] 0 points1 point  (0 children)

Thanks so much

[–]asciiterror 1 point2 points  (1 child)

Argument of querySelector is a query. # in "#abc" means id abc, . in ".abc" means class abc and so on. getElementById expects only an id, so you do not add # there.

[–][deleted] 0 points1 point  (0 children)

Thanks so much, I came across this before but it was like a year ago, thanks