如何在此html文档中打开指定的window.location页面?我需要在javascript中更改什么?
我做了一个旋转赢得网站,但随着每一次胜利,同一个网页被打开,每一次 每次只打开代码中提到的第一页,即prize_22.html 我想用他们各自的id打开页面 它必须在延迟5秒后打开 下面是javascript:如何在此html文档中打开指定的window.location页面?我需要在javascript中更改什么?,javascript,html,Javascript,Html,我做了一个旋转赢得网站,但随着每一次胜利,同一个网页被打开,每一次 每次只打开代码中提到的第一页,即prize_22.html 我想用他们各自的id打开页面 它必须在延迟5秒后打开 下面是javascript: jQuery(document).ready(function($){ $('.easywheel').easyWheel({ items: [ { //Here are some details id : 'a',
jQuery(document).ready(function($){
$('.easywheel').easyWheel({
items: [
{ //Here are some details
id : 'a',
name : 'PayTM cash',
message : 'You won PayTM cash of rupees 5000',
color : '#3498db',
win : true
},{
id : 'b',
name : 'Macbook Pro',
message : ' You won Macbook Pro 13" with touchbar',
color : '#ffc107',
win : true
},{
id : 'c',
name : 'Chocolate box',
message : 'You got one Ferrero Rpcher chocolate box',
color : '#f44336',
win : true
},{
id : 'd',
name : 'Lose',
message : 'You Lose :(',
color : '#3498db',
win : false
},{
id : 'e',
name : 'Trip to Dubai',
message : 'You won a trip to Dubai',
color : '#ffc107',
win : true
},{
id : 'f',
name : 'iPhone 11 Pro',
message : 'You get iPhone 11 Pro 256 gb',
color : '#f44336',
win : true
}
],
random: true,
button : '.spin-to-win',
onStart: function(results, spinCount, now) {
$('.spinner-message').css('color','#90A4AE');
$('.spinner-message').html('Spinning...');
},
onComplete : function(results,count,now){
$('.spinner-message').css('color',results.color).html(results.message);
console.log(results,count,now);
if (id='g'){
window.location="prize_22.html"
}
else if (id='b'){
window.location="prize_01.html"
}
else if (id='c'){
window.location="prize_44.html"
}
else if (id='d'){
window.location="prize_33.html"
}
else if (id='e'){
window.location="prize_555.html"
}
else{
window.location="prize_666.html"
}
}//open the above mentioned page
});
在这里使用
==
而不是singl=
if (id == 'g'){
window.location="prize_22.html"
}
else if (id == 'b'){
window.location="prize_01.html"
}
else if (id == 'c'){
window.location="prize_44.html"
}
else if (id == 'd'){
window.location="prize_33.html"
}
else if (id == 'e'){
window.location="prize_555.html"
}
else{
window.location="prize_666.html"
}
希望它能工作请使用
=
而不是=
。
在将来尝试使用
===
比=
更好,如果(id='g')(和其他)使用如果(results.id='g')
与(results.id='g')一起工作,请注意如果(id='b')不是如果(id='b')使用了“==”和“===”但仍然不工作,这应该是一个注释,不是答案。虽然我知道这“可能”是个问题,因为理解正确的语法很重要,但你的答案并没有解释太多,应该属于注释。请查看您的答案,以便更好地解释错误是什么,为什么是错误,以及应该如何更改代码以解决问题。一旦完成,我将取消我的否决票。