Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add class to a div when hover another one (Javascript)

I have a limited understanding of Javascriptan I am trying to add a class to a div when I hover another div Right now I can add a class to the same div but I would like to be able to add let's say the class blue to a div called first when I hover #second and #third.

current code :

    
    $(document).ready(function() {     
    $("#second, #third").hover(function(){     
    $(this).addClass("hover");    
    $(this).removeClass("hoverable");      
    },     
    function(){    
    $(this).removeClass("hover");     
        $(this).addClass("hoverable");     
    }  
    );     
    });        

My live website can be seen at : www.designinterieurm2.com/dev

like image 387
Francis Thibault Avatar asked Feb 17 '11 20:02

Francis Thibault


1 Answers

$(document).ready(function() {     
    $('#second, #third').hover(function(){     
        $('#first').addClass('blue');    
    },     
    function(){    
        $('#first').removeClass('blue');     
    });
});   
like image 182
Chris Baker Avatar answered Sep 24 '22 02:09

Chris Baker