La couleur ne change pas Help me


#1

https://www.codecademy.com/en/courses/web-beginner-fr-FR-t6eit/0/4

$(document).ready(function(){
    $('div').click(function(){
        $(this).fadeOut('fast')
            $('div').hover(function(){
                 $(this).addClass('red');
                 });
                 });
                 });

je doit changer la couleur du div quand je clique dessus en rouge . merci


#2

$(document).ready(function(){
    $('div').click(function(){
        $(this).fadeOut('fast')
            $('div').hover(function(){
                 $(this).addClass('red');
            });
        });
    });

Inproper nesting is the issue here. One event listener is nested in the other, when they should be independent of each other.

$(document).ready(function(){
    $('div').click(function(){
        $(this).fadeOut('fast')
    });
    $('div').hover(function(){
         $(this).addClass('red');
    });
});