('.main') vs ('body')


why is main prefixed with a ',' while body is not?


Could you give an example of the code you are referring to so someone could enlighten you on it?


Hi Jcamp23,

It's a dot (.), not a comma (,).
The dot represents a class name, a hash sign (#) represents an id, and nothing represents a tag name.

So, with this HTML:

<div class="example"></div>
<div id="example"></div>

You could select each element like this in jQuery (in order):


If you didn't have the distinguishing character (., #, or nothing) in front of your selector, the computer wouldn't know which element you wanted to select, which would cause problems :slightly_smiling:

Does this help?


Ok, thank you. This does help.

I'm doing the Build an Interactive Website tutorial where it asks you to move the menu and screen around. I don't believe it discusses element types. Is there a recommended tutorial for that?



I'd recommend you take these courses first:

  1. HTML & CSS
  2. Make A Website
  3. jQuery



Hi quobogeba,

The code I was asking about was:

var main = function() {
/* Push the body and the nav over by 285px over */
$('.icon-menu').click(function() {
left: "0px"
}, 200);

  left: "285px"
}, 200);



Ok, thanks for the recommendation!


@jcamp23 As @zystvan stated above, the reason you don't select "body" as ".body" is because it wasn't assigned a class. If you were to give a <div></div> a class, being whatever you like, but I'm gonna give mine the class of 'div', it would look like this <div class="div"></div>. Now, when you select that in jQuery, it will look like this: $('.div'), and if you were to leave it without a class, you would select it like so: $('div').

I hope this helps even just the smallest bit.