Change background color on mouseover and remove it after mouseout

前端 未结 7 1117
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 10:38

I have table which class is forum. My jquery code:



        
7条回答
  •  暖寄归人
    2020-12-05 10:42

    Try this , its working and simple

    HTML

    ​​​​​​​​​​​​​​​​​​​​​
    
    
        
    test
    ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

    Javascript

    $(document).ready(function() {
        var colorOrig=$(".forum").css('background-color');
        $(".forum").hover(
        function() {
            //mouse over
            $(this).css('background', '#ff0')
        }, function() {
            //mouse out
            $(this).css('background', colorOrig)
        });
    });​
    

    css ​

    .forum{
        background:#f0f;
    }​
    

    live demo

    http://jsfiddle.net/caBzg/

提交回复
热议问题