Can you remove the class on which you selected an element?

Question

In the context of this exercise, can you remove the class on which you selected an element?

Answer

Yes, you can remove the class from the element you selected them on. For example, you can do the following,

$('.className').removeClass('className');

It is important to keep in mind that once you remove a class, you cannot select it again using that class name, and to reapply it to an element, you must select it using another attribute.

5 Likes

In this https://www.codecademy.com/paths/web-development/tracks/learn-jquery/modules/learn-jquery-style-methods/lessons/jquery-style-methods/exercises/remove-class I do not see the visual effect of $(’.nav-menu’).removeClass(‘hide’); after commentint it out, The webpage still behaved the same.

3 Likes