네비게이션의 색상이 특정 사진에 대해 읽기 어려웠으므로 특정 한 페이지에 대해 변경해야합니다. 다음은 HTML입니다 : 코드의 엄청난 양에 대한a : 링크 색상을 jQuery로 변경했습니다. 이제는 내 호버가 작동하지 않습니다.
switch (i)
{
case 0:
$('.content').fadeOut(500);
$('a.navItem:link').animate({color: "#333"});
$('#navBiog a.navItem:hover,a:active',
'#navConductor a.navItem:hover,a:active',
'#navOrchestrator a.navItem:hover,a:active',
'#navGallery a.navItem:hover,a:active',
'#navContact a.navItem:hover,a:active').css({'color': ''});
break;
case 1:
$('.content').slideUp(700);
$('#biogContent').slideDown(700, function(){
$('h1').animate({color: "#cc0099"});
$('a.navItem:link').animate({color: "#333"});
$('#navBiog a.navItem:hover,a:active',
'#navConductor a.navItem:hover,a:active',
'#navOrchestrator a.navItem:hover,a:active',
'#navGallery a.navItem:hover,a:active',
'#navContact a.navItem:hover,a:active').css({'color': ''});
});
break;
case 2:
$('.content').slideUp(700);
$('#condContent').slideDown(700, function(){
$('h1').animate({color: "#ff9900"});
$('a.navItem:link').animate({color: "#333"});
$('#navBiog a.navItem:hover,a:active',
'#navConductor a.navItem:hover,a:active',
'#navOrchestrator a.navItem:hover,a:active',
'#navGallery a.navItem:hover,a:active',
'#navContact a.navItem:hover,a:active').css({'color': ''});
});
break;
case 3:
$('.content').slideUp(700);
$('#orchContent').slideDown(700, function(){
$('h1').animate({color: "#66cc66"});
$('a.navItem:link').animate({color: "#ffffff"});
$('#navBiog a.navItem:hover,a:active',
'#navConductor a.navItem:hover,a:active',
'#navOrchestrator a.navItem:hover,a:active',
'#navGallery a.navItem:hover,a:active',
'#navContact a.navItem:hover,a:active').css({'color': ''});
});
break;
case 4:
$('.content').slideUp(700);
$('#mediaContent').slideDown(700, function(){
$('h1').animate({color: "#6699ff"});
$('a.navItem:link').animate({color: "#333"});
$('#navBiog a.navItem:hover,a:active',
'#navConductor a.navItem:hover,a:active',
'#navOrchestrator a.navItem:hover,a:active',
'#navGallery a.navItem:hover,a:active',
'#navContact a.navItem:hover,a:active').css({'color': ''});
});
break;
case 5:
$('.content').slideUp(700);
$('#contactContent').slideDown(700, function(){
$('h1').animate({color: "#ff0"});
$('a.navItem:link').animate({color: "#333"});
$('#navBiog a.navItem:hover,a:active',
'#navConductor a.navItem:hover,a:active',
'#navOrchestrator a.navItem:hover,a:active',
'#navGallery a.navItem:hover,a:active',
'#navContact a.navItem:hover,a:active').css({'color': ''});
});
break;
default:
break;
}
죄송합니다
<div id='nav'>
<ul>
<li id='navBiog'><a href="javascript:void(0)" onclick="imageChange(1, 400)" class="navItem">biography</a></li>
<li id='navConductor'><a href="javascript:void(0)" onclick="imageChange(2, 400)" class="navItem">conductor</a></li>
<li id='navOrchestrator'><a href="javascript:void(0)" onclick="imageChange(3, 400)" class="navItem">orchestrator</a></li>
<li id='navGallery'><a href="javascript:void(0)" onclick="imageChange(4, 400)" class="navItem">gallery</a></li>
<li id='navContact'><a href="javascript:void(0)" onclick="imageChange(5, 400)" class="navItem">contact</a></li>
</ul>
</div>
CSS
a.navItem:link,a.navItem:visited{
font-family:"Helvetica", "Arial", sans-serif;
font-size:20px;
text-align:right;
padding:4px 6px 4px 6px;
text-decoration:none;
color:#333;
transition:color 1s;
-moz-transition:color 1s; /* Firefox 4 */
-webkit-transition:color 1s; /* Safari and Chrome */
-o-transition:color 1s; /* Opera */
}
#navBiog a.navItem:hover,a:active {color:#cc0099;}
#navConductor a.navItem:hover,a:active {color:#ff9900;}
#navOrchestrator a.navItem:hover,a:active {color:#66cc66;}
#navGallery a.navItem:hover,a.navItem:active {color:#6699ff;}
#navContact a.navItem:hover,a.navItem:active {color:#FF0;}
그리고 jQuery를, 그러나 그것은 말로 상당히 어렵다. 어쨌든 초기 색상 변경은 작동하지만 호버는 작동하지 않습니다. nav의 각 링크가 마우스로 가리키면 다른 색상으로 표시된다는 사실은 분명히 복잡합니다 ...
감사합니다. 진심으로 사과드립니다. 이것은 어리석은 어리석은 질문이다/천 번 질문하고 나는 그것을 발견 할 수 없었다.
왜 각 케이스에 대해 선택자와 코드를 동일한 덩어리로 반복합니까? 디버깅/최신 유지가 미친 짓 아닌가? 그들은 slideDown의 ID를 제외하고 모두 똑같지 않습니까 ??? –
Chrome에서 나를 위해 작동하는 것처럼 보입니다. [look] (http://jsfiddle.net/cambraca/Vye5m/2) 호버에서 색상이 변경됩니다. (내가 잘못 이해하지 않는 한) – cambraca
한 번 '오케스트레이터' 링크가 클릭되었습니다. 링크의 색상이 변경되지만, 호버가 작동하지 않습니다. 실제로, jsfiddle에서 링크는 색을 변경하지 않습니다 ... – user1148106