6/14. Removing or Adding Classes


#1

Someone help me. I pretty sure this is right but it isn't WORKING. Pls tell me why.

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

#2

I also tried this code:

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

#3

Should be:

$('#text').addClass('highlighted');

Remove a single class:

$('#text').removeClass('highlighted');

#4

Okay. let me try it.


#5

Thank you. it worked. :slight_smile:


#6

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