Stuck in question 5


#1

1.can a class naming with a break space?cause i saw it using class="article current" to name the class.
2.in this exercise, i can't see any styling in style.css about the current class? so how can the javascript change the styling to current class using $(this).addClass('current') ?
please someone kindly help me figure these out!!


#2

I would refer back to the jQuery course to answer that question, but essentially it's because you're clicking on the div that the class is a part of.


#3

Hi runping,

@lolman is correct, going through the jQuery course would be a good idea, but I don't think it will answer your questions here.

Yes. A space between classes represents two classes. So,

<tag class="one two"></tag>

could be selected:

// like this: 
.one
// or like this: 
.two

Classes are normally used for styling, but that doesn't mean they're always used to style stuff. Right now, the .current class is being used only for functional purposes, keeping track of which article you're on. Having a class in the CSS means pretty much nothing; you can style nonexistent classes in the CSS, for example.


#4

thanks for the answer of the first question, i think i have figured it out. there is still another question: is the $('p').removeClass('name') method just remove the name of the p element with 'name' and set it to null?


#5

more specific, in the question i got an element named 'article current', when i use $('.article').removeClass('current'), does it mean i will remove the 'current' key word and set it to 'article'?


#6

@javawhiz25881 No. Currently, there's this:

<div class="article current">...</div>

$('.article').removeClass('current'); leaves this:

<div class="article">...</div>

If you have only one class, it leaves an empty class="" attribute. But it doesn't add any classes when you remove one, and it doesn't set it to null or anything like that :)

Does this answer your questions?


#7

thank you very much! It is pretty clear now!