Variable name: ".btn" vs "btn"?


#1

When do we have to use a period in front of the variable name and when do we not have to?


#2

.btn is used to target a btn class of your HTML element in JS(JQuery). [Remember that a class is targeted using . while an id is #].

This is an example of a btn class.

<div class="btn">
</div>

#3

Can you explain to me why we don't use ".active-dot" for the removeClass() and addClass() but "active-dot" instead? I thought active-dot is a class in my HTML as well?

var currentDot = $('.active-dot');
var nextDot = currentDot.next();
currentDot.removeClass('active-dot');
nextDot.addClass('active-dot');


#4

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