Yannis Dran
Yannis Dran

Reputation: 1529

Why .removeClass not working?

Here is the jsfiddle code

I found this problem during a CodeAcademy lesson.

Same goes for .addClass, .toggleClass

   $(document).ready(function() {
    $('#title').click(function() {
        $(this).removeClass('.highlighted');
    });
});

Upvotes: 2

Views: 223

Answers (3)

Suresh Pattu
Suresh Pattu

Reputation: 6219

Don't put dot -----> [ . ] before the class name remove that then it will work fine :) Use this

 $(document).ready(function() {
    $('#title').click(function() {
        $(this).removeClass('highlighted');
    });
});

Upvotes: 2

Nandu
Nandu

Reputation: 3126

try this

$(document).ready(function() {
    $('#title').click(function() {
        $(this).removeClass('highlighted');
    });
});

http://jsfiddle.net/v6FRU/1/

Upvotes: 2

phnkha
phnkha

Reputation: 7892

try this

$(this).removeClass('highlighted');

Documentation:

http://api.jquery.com/removeClass/

Upvotes: 4

Related Questions