gpt4 book ai didi

javascript - 如何使用jquery替换html中的图像

转载 作者:行者123 更新时间:2023-11-28 13:28:49 24 4
gpt4 key购买 nike

我编写了下面的代码,使用 jquery 替换图像来显示图像的运动事件,但是找不到图像 - 控制台输出中显示错误。我已经上传了所有图片,并且所有图片都有读取、写入和执行的权限。

var i = 1;                     //  set your counter to 1

var strOutput;
var luckyNumber;
var imgStr="";
var time;
function ShowLuckyNumber() {
$('#play').css('display','none');
$('#btnLuck').css('display','none');
$('#numbers').css('display','none');
$('.TestRotator').css('display','block');

var rotator = document.getElementById('rotator'); // change to match image ID
var imageDir = 'http://perfectinter.net/subdomains/lottefree/image/';
var delayInSeconds = 1;
var images = ['draw_001.jpg', 'draw_002.jpg', 'draw_003.jpg', 'draw_004.jpg', 'draw_005.jpg', 'draw_006.jpg', 'draw_007.jpg', 'draw_008.jpg', 'draw_009.jpg','draw_010.jpg','draw_011.jpg', 'draw_012.jpg', 'draw_013.jpg', 'draw_014.jpg', 'draw_015.jpg', 'draw_016.jpg', 'draw_017.jpg', 'draw_018.jpg', 'draw_019.jpg','draw_020.jpg','draw_021.jpg', 'draw_022.jpg', 'draw_023.jpg', 'draw_024.jpg', 'draw_025.jpg', 'draw_026.jpg', 'draw_027.jpg', 'draw_028.jpg', 'draw_029.jpg','draw_030.jpg','draw_031.jpg', 'draw_032.jpg', 'draw_033.jpg', 'draw_034.jpg', 'draw_035.jpg', 'draw_036.jpg', 'draw_037.jpg', 'draw_038.jpg', 'draw_039.jpg','draw_040.jpg','draw_041.jpg','draw_042.jpg','draw_043.jpg','draw_044.jpg','draw_045.jpg','draw_046.jpg','draw_047.jpg','draw_048.jpg','draw_049.jpg','draw_050.jpg','draw_051.jpg','draw_052.jpg','draw_053.jpg','draw_054.jpg','draw_055.jpg','draw_056.jpg','draw_057.jpg','draw_058.jpg','draw_059.jpg','draw_060.jpg','draw_061.jpg','draw_062.jpg','draw_063.jpg','draw_064.jpg','draw_065.jpg','draw_066.jpg','draw_067.jpg','draw_068.jpg','draw_069.jpg','draw_070.jpg','draw_071.jpg','draw_072.jpg','draw_073.jpg','draw_074.jpg','draw_075.jpg','draw_076.jpg','draw_077.jpg','draw_078.jpg','draw_079.jpg'];
var num = 0;
var value=1;
var path="";
var changeImage = function () {
var len = images.length;
//rotator.src = imageDir + images[num++];
path=imageDir + images[num++];
$('#rotator').attr('src',path);

//alert(rotator.src);
if (num == len) {
num = 0;
resetfun();
}
};
time=setInterval(changeImage, delayInSeconds * 50);
}

function resetfun()
{
clearTimeout(time);
luckyNumber=Math.floor((Math.random() * 9999) + 1);

var dataString ='number='+luckyNumber;
/* $.ajax({
type: "POST",
url: "playentry.php",
data: dataString,
success: function(data){
$("#dealsptab").html(data);
}
});*/
var check=$('#dealpt').val();
if(check==0)
{
document.location.href='dealpoint.php';
}
var luckyNums = document.getElementById("numbers");

var frontTag = "<span>";
var backTag = "</span>";

if (luckyNumber < 10)
strOutput = "000" + luckyNumber;
else if (luckyNumber < 100)
strOutput = "00" + luckyNumber;
else if (luckyNumber < 1000)
strOutput = "0" + luckyNumber;
else
strOutput = "" + luckyNumber;

var j=0;
for (var i = 0; i < 4; i++) {
imgStr += frontTag + strOutput.substr(i, 1) + backTag;
j=i+1;
$('#sp'+j).val(strOutput.substr(i, 1));
}
$('.TestRotator').css('display','none');
$('#play').css('display','block');
$('#btnLuck').css('display','block');
$('#numbers').css('display','block');
return false;
}

最佳答案

问题是你的网址:你写了 http://perfectinter.net/subdomains/lottefree/image/draw_001.jpg不存在,http://perfectinter.net/subdomains/lottefree/images/draw_001.jpg这就是您正在寻找的!

简单来说,你写的“image”不存在,“images”是正确的目录

关于javascript - 如何使用jquery替换html中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26774469/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com