Help needed


given the following code:
var main = function (){


    var currentSlide = $('.active-slide');
    var nextSlide =;




why does the removeClass('active-slide'); work without using '.active-slide' I taught the dot is needed to call class in jquery but here and also using the addClass('active-slide'), it is used without the dot. And that was the correct syntax. Please help me understand y. Thanks


Hey Lawreneagles,

When we select something using jQuery, we could select:

$('#example') // an id
$('.example') // a class
$('example') // or a tag

So something is needed to distinguish between each of those, especially in cases where you might have the same #id and .class name for some reason. With add/removeClass() however, jQuery knows we're dealing with a .class, so no distinction is necessary.

I hope this helps you!


Thank you for this answer. I had the same question. You just made everything click with that simple explanation.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.