Transcript from the "Image Gallery Q&A" Lesson
>> Speaker 1: So up at the top, when we did the query selector, we used dot prev, dot next to get that class name. But then, down inside of the event listeners, I was saying remove and add dot active. I didn't get any errors cuz-
>> Brian Holt: I mean,
>> Brian Holt: That doesn't do what you want it to do, right?
>> Speaker 1: Yeah.
>> Brian Holt: Yeah.
>> Speaker 1: Well, that's the name of a class, so I have to put a period first. But apparently, not when you are adding and removing.
>> Brian Holt: Yes, so this is a good point to bring up. Let's just take a look at what it looks like in the HTML here.
[00:00:34] Notice this is not a class called disabled, it's actually an attribute on the element called disabled. So this is actually something built into the browser. Because we often have to enable and disable buttons, right? So we could have just made this like a class here and called it disabled and worked with that and added the same style.
[00:00:54] This is inferior to what we've chosen to do for two reasons. One, just like I was showing you here, I don't have to detect inside of my event listeners if this is disabled or not, because it will not fire events if it's disabled, right? And this works with inputs, this works with a bunch of stuff as well.
>> Speaker 1: I was talking about next and previous, which are classes.
>> Brian Holt: Right.
>> Speaker 1: So when I was trying to add and remove them.
>> Brian Holt: So when you were saying instead of saying classless dot add, you were doing something like-
>> Speaker 1: No, I had classless dot add, quote, dot active.
>> Brian Holt: Dot active, gotcha.
>> Speaker 1: Yeah, and that didn't work. But it didn't give me any errors, so I was like-
>> Brian Holt: That's interesting.
>> Speaker 1: And it confused me because up at the top when we did query selector, we did have to put the period.
>> Brian Holt: Yeah, it is kind of contextual in that sense, yeah.