2014-03-04 23 views
-1

我正在做页面导航,我有焦点问题,所以我想聚焦将导航元素不在页面上的任何地方。Jquery导航重点/出

$('nav ul li').focusin(function(){ 
$(this).css('background-color','#00979B'), 
$(this).css('color','#fff'); 
}); 
$('nav ul li').focusout(function(){ 
$(this).css('background-color','#fff'), 
$(this).css('color','#00979B'); 
}); 
+0

我不明白你的问题。你能提供更详细的信息吗? –

+0

你应该使用CSS:[pseudo-classes](http://www.w3.org/TR/CSS21/selector.html#dynamic-pseudo-classes)':hover':''focus'。所以'nav ul li:hover {background-color:#00979B;颜色:#FFF; }'。 – Sam

回答

0

你要悬停 - http://api.jquery.com/hover/

$('nav ul li').hover(function() { 
    $(this).css('background-color', '#00979B'), 
    $(this).css('color', '#fff'); 
}, function() { 
    $(this).css('background-color', '#fff'), 
    $(this).css('color', '#00979B'); 
}); 

http://jsfiddle.net/8Tz3n/

+0

如何在第一次悬停时离开时间 http://jsfiddle.net/EXDmL/1/ –