Click function: why isn't the following code '.current'?


#1

I am working on the click function section. Later on in the course we use '.current' but here it is just 'current' being called. Why is this? Something to do with removeClass() being a regular function and not the event handler?

var main = function() {
$('.article').click(function(){
$('.article').removeClass('current');
$('.description').hide();
$(this).addClass('current');
$(this).children('.description').show();
})
};


#2

Hi Greg,

The dot (.) in front of a class name is to distinguish it from an #id or tag selector. But with addClass(), removeClass(), and toggleClass(), the dot isn't necessary because the computer knows it's dealing with a class, so no need to distinguish the different things there :slightly_smiling:

Does this help you?


#3

@greg_r_roche
Look also at leonard's post. Fully explained.
The O shortcut


#4

Yes, thank you. Much appreciated.