2014-08-27 188 views
0

我需要更改悬停在不同类的CSS。以下是密码Jquery:悬停功能

<li class="dropdown whitedrop" id="dropdown" style="width: 229px;"> 
    <div class="greenStripe"></div> <a data-target="#" style="cursor: Default;margin-left: 50px;width: 180px;" class="fnd-nav-link" data-toggle="dropdown"><span id="loggedon_lable">Logged on:</span> 
     <span id="loggedon_user"></span><b class="caret"></b></a> 
    <ul id="whitedropdown-menu" class="whitedropdown-menu fnd-tweak-dropdown" style=""> 
     <li class="borderli disabledMenu"> <a tabindex="-1" style="cursor: default">My Profile</a> 
     </li> 
     <li class="borderli disabledMenu"> <a tabindex="-1" style="cursor: default">Settings</a> 
     </li> 
    </ul> 
</li> 

在悬停时,'whitedropdown-menu'我需要更改'greenStripe'的背景。

我试过,

.whitedropdown-menu:hover .greenStripe { 
    background:#029f1c; 
} 

它没有工作actually.But我需要它在jQuery中没有CSS。 对于我试过,

$(".whitedropdown-menu").hover(function() { 
    $(".greenStripe").css('background', '#029f1c'); 
}); 

但一旦我悬停,背景的变化,当我不徘徊它没有得到回复。

请帮忙, 谢谢。

+0

。 – 2014-08-27 13:25:18

回答

1
$(".whitedropdown-menu").hover(function(){ 
    // Function called when hover 
    // Go from background1 to background2 

}, function() { 
    // Function called when hover end 
    // Go from background2 to background1 
}); 

.hover()

0

尝试鼠标移出代码:

$(".whitedropdown-menu").mouseout(function() { 
    $(".greenStripe").css('background','#029f1c'); //change this color to the color you want 
    }); 
0

请与下面的代码片段尝试。

$(".whitedropdown-menu").mouseout(function() { 
    $(".greenStripe").css('background','#029f1c'); 
}); 

您必须再添加一个jquery事件来处理这个事件。 OnMouseOut你必须再次改变背景。

0

一次尝试将鼠标光标离开你的容器移动样式:

$('.whitedropdown-menu').mouseout(function() { 
    $('.greenStripe').css('background','none'); //replace the none with the initial background color 
}); 
你必须告诉它手动删除样式