<section id="wheel_section">
<nav class="position">
<a href="#" class="pos-1">LOC 1</a>
</nav>
<nav class="position">
<a href="#" class="pos-2">LOC 2</a>
</nav>
<nav class="position">
<a href="#" class="pos-3">LOC 3</a>
</nav>
<nav class="position">
<a href="#" class="pos-4">LOC 4</a>
</nav>
<nav class="position">
<a href="#" class="pos-5">LOC 5</a>
</nav>
</section>
<section id="wheel_wheel">
<p>
<img id="the_wheel" src="position_1.gif" width="233" height="233" align="absmiddle" />
</p>
</section>
试图更改悬停时的图像(pos-1,pos-2等等)需要更改“the_wheel”中的图像。这些都是gif,而且id越高,gif的旋转速度越快。如果我将鼠标移动到左侧,那么ID就会变小,GIF的旋转速度会变慢,这就是它们的制作方式。将鼠标悬停在ID上更改图像
尝试这样:
$(document).ready(function(){
$("#wheel_section .position .pos-1").hover(function() {
$('img#the_wheel').attr("src", "position_1.gif");
});
$("#wheel_section .position .pos-2").hover(function() {
$('img#the_wheel').attr("src", "position_2.gif");
});
$("#wheel_section .position .pos-3").hover(function() {
$('img#the_wheel').attr("src", "position_3.gif");
});
$("#wheel_section .position .pos-4").hover(function() {
$('img#the_wheel').attr("src", "position_4.gif");
});
$("#wheel_section .position .pos-5").hover(function() {
$('img#the_wheel').attr("src", "position_5.gif");
});
});
,但我想有一个更好的aproach也..还是我错了? :)
[会这样满足](http://jsfiddle.net/Shef/RCyV6/)? – Shef
谢谢。我复制相同的代码在我的本地主机上,悬停将获得position_undefined.gif –
你也必须改变标记,这就是为什么。 :) – Shef