jQuery - addClass/removeClass functions - dot notation


#1

Why does jQuery not allow using addClass/removeClass('.CLASS') but requires ('CLASS') without the period? I got really hung up on this as in CSS, etc. the 'dot' always signifies that you are specifying a class.

Probably just me being picky but I was curious if anyone else knew why they developed the framework this way in this instance.

Good luck on your programming journey to everyone!


#2

Hi Kevin,

You know what the dot is for - it specifies that you're using a class, rather than an id or tag. But with add/remove/toggleClass(), there's no need to specify that, because the only thing it's going to get as an input is a class, so the dot (.) isn't necessary there :slightly_smiling:


#3

Thanks! I was stuck in that lesson forever!:relaxed:


#4

This topic is solved.