0
我想使这个简单的图像旋转器,但像往常一样,我的代码不起作用。我想2个图像(“图像1”和“图像2”)jQuery图像旋转器
$x = 0;
function rotateImage(){
if($x == 0){ //if function is being called for the first time
$x = 1;
}
$(".window").html("<img src=\"../images/image" + $x + ".png\" />");
$x = $x + 1;
if($x > 2)
$x = 1; //reset x to 1 if last image has been reached
}
rotateImage(); //first function call
setInterval("rotateImage()", 1000); //call function every second
此搜索显示出来,但没有交换回事之间切换。
由于提前,
马特
嗯,它似乎没有工作。在回答你的其他问题时,我有一个带有“窗口”类的div(可以想象它是一个相当可怜的名字)。 – Matt 2010-07-13 17:01:34
最后两行代码在哪里执行?它在document.ready/onload函数中吗? – Fosco 2010-07-13 18:51:00
是的,所有上面的代码都在document.ready函数中。 – Matt 2010-07-13 22:39:33