Quick query - reminder: why use the dot . in front of a class?


#1

Can anyone remind me why we use the full stop/dot (.) in front of a class please. I was going through this exercise and need a reminder.

thanks


#2

Hey Sunnyjeans,

That's because when you select something, you could select it three basic ways:

$('#example') // with an id; selects <div id="example"></div>
$('.example') // with a class; selects <div class="example"></div>
$('example') // with a tag name; selects <example></example>

The symbols are needed to distinguish, say, a class from an id, since they might be the same but on different elements or something :)


#3

Thank you Zystvan, that makes sense now. :smile: