JSFiddle - http://jsfiddle.net/4Hhhx/
相关的 Javascript 代码 -
var menuItemNames = ['#home', '#about', '#projects', '#resume', '#contact'];
$('#home').click(safeSelect('#home'));
$('#about').click(safeSelect('#about'));
$('#projects').click(safeSelect('#projects'));
$('#resume').click(safeSelect('#resume'));
$('#contact').click(safeSelect('#contact'));
function safeSelect(divId) {
console.log('selecting '+divId);
if (!$(divId).length){
return;
}
for (var i = 0; i < menuItemNames.length; i++){
if (menuItemNames[i]===divId){
$(divId).removeClass('selected unselected').addClass('selected');
}
else {
$(divId).removeClass('selected unselected').addClass('unselected');
}
}
}
相关的 CSS 代码 -
nav ul li a:hover {
opacity: 1.0;
padding-right: 3.0em;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
nav ul li a.selected {
opacity: 1.0;
}
nav ul li a.unselected {
opacity: .5;
}
我想要以下行为 -
悬停时, opacity: 1 和过渡。在 class="active" 上,不透明度:1。
我究竟做错了什么?