【发布时间】:2015-08-28 17:33:01
【问题描述】:
我知道这个问题已经被问过很多次了,我试着查看答案并遵循它们。但我似乎无法弄清楚如何用我的特定代码应用这些答案,现在我被卡住了。如果有人可以查看它并帮助我,将不胜感激。
简单地说,我只想制作一个自动播放功能,可以播放这 6 张图像,还可以播放和暂停。理想情况下,只需一个按钮。就这样。 [JSfiddle 链接。虽然没有图片。也许有帮助?][1]
window.onload = function() {
function show1() {
document.getElementById("showingImage").src = "images/.jpg";
}
function show2() {
document.getElementById("showingImage").src = "images/2.jpg";
}
function show3() {
document.getElementById("showingImage").src = "images/3.jpg";
}
function show4() {
document.getElementById("showingImage").src = "images/4.jpg";
}
function show5() {
document.getElementById("showingImage").src = "images/5.jpg";
}
function show6() {
document.getElementById("showingImage").src = "images/6.jpg";
}
var one = document.getElementById("one");
one.onmouseover = show1;
var two = document.getElementById("two");
two.onmouseover = show2;
var three = document.getElementById("three");
three.onmouseover = show3;
var four = document.getElementById("four");
four.onmouseover = show4;
var five = document.getElementById("five");
five.onmouseover = show5;
var six = document.getElementById("six");
six.onmouseover = show6;
}
#container {
width: 800px;
margin: 0 auto;
background-color: red;
}
#showingImage {
width: 800px;
height: 400px;
}
#thumbnail {
max-height: 50px;
margin: 10 auto 10 10;
text-align: center;
}
HTML:
<body>
<div id="container">
<div>
<img id="showingImage" src="images/1.jpg">
</div>
<div id="thumbnail">
<span id="one"><img id="thumbnail" src="images/1.jpg"></span>
<span id="two"><img id="thumbnail" src="images/2.jpg"></span>
<span id="three"><img id="thumbnail" src="images/3.jpg"></span>
<span id="four"><img id="thumbnail" src="images/4.jpg"></span>
<span id="five"><img id="thumbnail" src="images/5.jpg"></span>
<span id="six"><img id="thumbnail" src="images/6.jpg"></span>
</div>
</div>
</body>
如果您能解释如何将 Jquery fadeIn 应用于鼠标悬停部分和自动播放,则可以加分。
【问题讨论】:
-
您的 JSFiddle 链接需要更多链接。
标签: javascript jquery html css autoplay