JavaScript图片切换怎么调慢切换速度
我只是选修的,几乎不懂代码,这是我拷来的效果,谁能告诉我怎么调。。。。这里切换的速度太快了,怎么可以调慢点?代码我不懂看<scripttype="text/javascr...
我只是选修的,几乎不懂代码,这是我拷来的效果,谁能告诉我怎么调。。。。这里切换的速度太快了,怎么可以调慢点?代码我不懂看
<script type="text/javascript">
window.onload = function ()
{
var oBox = document.getElementById("box");
var aUl = document.getElementsByTagName("ul");
var aImg = aUl[0].getElementsByTagName("li");
var aNum = aUl[1].getElementsByTagName("li");
var timer = play = null;
var i = index = 0;
var bOrder = true;
//лť
for (i = 0; i < aNum.length; i++)
{
aNum[i].index = i;
aNum[i].onmouseover = function ()
{
show(this.index)
}
}
//껮رնʱ
oBox.onmouseover = function ()
{
clearInterval(play)
};
//뿪Զ
oBox.onmouseout = function ()
{
autoPlay()
};
//Զź
function autoPlay ()
{
play = setInterval(function () {
//жϲ˳
bOrder ? index++ : index--;
//
index >= aImg.length && (index = aImg.length - 2, bOrder = false);
//
index <= 0 && (index = 0, bOrder = true);
//ú
show(index)
},2000);
}
autoPlay();//Ӧ
//ͼƬл, 뵭Ч
function show (a)
{
index = a;
var alpha = 0;
for (i = 0; i < aNum.length; i++)aNum[i].className = "";
aNum[index].className = "current";
clearInterval(timer);
for (i = 0; i < aImg.length; i++)
{
aImg[i].style.opacity = 0;
aImg[i].style.filter = "alpha(opacity=0)";
}
timer = setInterval(function () {
alpha += 2;
alpha > 100 && (alpha =100);
aImg[index].style.opacity = alpha / 100;
aImg[index].style.filter = "alpha(opacity = " + alpha + ")";
alpha == 100 && clearInterval(timer)
},20);
}
};
</script> 展开
<script type="text/javascript">
window.onload = function ()
{
var oBox = document.getElementById("box");
var aUl = document.getElementsByTagName("ul");
var aImg = aUl[0].getElementsByTagName("li");
var aNum = aUl[1].getElementsByTagName("li");
var timer = play = null;
var i = index = 0;
var bOrder = true;
//лť
for (i = 0; i < aNum.length; i++)
{
aNum[i].index = i;
aNum[i].onmouseover = function ()
{
show(this.index)
}
}
//껮رնʱ
oBox.onmouseover = function ()
{
clearInterval(play)
};
//뿪Զ
oBox.onmouseout = function ()
{
autoPlay()
};
//Զź
function autoPlay ()
{
play = setInterval(function () {
//жϲ˳
bOrder ? index++ : index--;
//
index >= aImg.length && (index = aImg.length - 2, bOrder = false);
//
index <= 0 && (index = 0, bOrder = true);
//ú
show(index)
},2000);
}
autoPlay();//Ӧ
//ͼƬл, 뵭Ч
function show (a)
{
index = a;
var alpha = 0;
for (i = 0; i < aNum.length; i++)aNum[i].className = "";
aNum[index].className = "current";
clearInterval(timer);
for (i = 0; i < aImg.length; i++)
{
aImg[i].style.opacity = 0;
aImg[i].style.filter = "alpha(opacity=0)";
}
timer = setInterval(function () {
alpha += 2;
alpha > 100 && (alpha =100);
aImg[index].style.opacity = alpha / 100;
aImg[index].style.filter = "alpha(opacity = " + alpha + ")";
alpha == 100 && clearInterval(timer)
},20);
}
};
</script> 展开
展开全部
timer = setInterval(function () {
alpha += 2;
alpha > 100 && (alpha =100);
aImg[index].style.opacity = alpha / 100;
aImg[index].style.filter = "alpha(opacity = " + alpha + ")";
alpha == 100 && clearInterval(timer)
},20);
你应该指是这里,最后一行最后的20,这个你可以试着改大一点,单位是毫秒
更多追问追答
追问
不行啊,我改了个10,然后他变隔张隔张的切换了。。。
追答
我是说让你改大点啊...,改成50试试
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询