No 6 Hover question


#1

$(document).ready(function(){

$("div").hover(
function(){
$(this).addClass("active");
},
function(){
$(this).removeClass("active");
}
);

});

why is it that active is not ".active" instead of just "active".


#2

.addClass only works with classes, so it knows that you need a class.

You don't have to put a dot in this case.


#3

because you are just adding a class to the html element and you wish to call it "active" but if you wanted to to refer to the element with that class then you would use ".active"
eg: if i wanted to append some text to that div after adding the class then i could use the class like this

$(".active").after("some random text");

#4

That makes sense. Thank you