6. Adding and Removing Classes


#1


https://www.codecademy.com/courses/web-beginner-en-v6phg/1/1?curriculum_id=50a3fad8c7a770b5fd0007a1#


Code is accepted; however, if I do not put a ' # ' in front of 'text', I will get an ERROR message: Oops, try again. It looks like your #text doesn't have the class .highlighted. Check the Hint if you need help! "

I am confused, because in the exercise, it clearly states: "Remember: You aren't selecting anything, you are modifying your element. This means that you do NOT need # or . before your class.".

Why do the instructions say I do not need #, but if I don't put # the code is not accepted?


$(document).ready(function() {
    $('#text').click(function() {
    $(this).addClass('highlighted');
    });
});


#2

The statement refers to,

Learners often mistakenly include a dot in this expression. You have not, which is correct.


#3

Ohhh. Got it. I forgot text is an ID, not a class. Thank you.


#4

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