我遇到的问题是在if语句中,.clicks()不起作用。我需要单击按钮并重新运行脚本但它不起作用。 SetTimeout(start,5000)帮助它重复但是让脚本一次运行几次。
document.getElementById('sound-toggle').onclick = function() {
var startingBet = 5;
startingBet = parseFloat(startingBet);
document.getElementById('bet-bt').onclick = function () {
function start() {
//show if it is getting chip amount
//var rr = document.getElementById('bet-rb-2').innerHTML; //neerdsa classs s3elec5to9r
//var rr = document.getElementById('bet-rb-2').innerHTML;
//
setTimeout(start,5000);
//select the result of the spin
var result = document.getElementById('result-text').innerHTML;
alert(result.length);
if (result.length == 5) { //lost
alert('lost');
//document.getElementById("bet-bt").click();
break;
} else if ( result.length == 4) { //won
alert('won');
//document.getElementById("bet-bt").click();
break;
} else {
alert('something is wrong' );
///document.getElementById("bet-bt").click();
break;
}
}
start();
};
};
答案 0 :(得分:1)
可能会尝试这样的事情:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#sound-toggle').click(function(){
var startingBet = 5;
startingBet = parseFloat(startingBet);
});
$('#bet-bt').click(function(){
setTimeout(start,50);
});
});
function start() {
//show if it is getting chip amount
//var rr = document.getElementById('bet-rb-2').innerHTML; //neerdsa classs s3elec5to9r
//var rr = document.getElementById('bet-rb-2').innerHTML;
//
//select the result of the spin
var result = document.getElementById('result-text').innerHTML;
alert(result.length);
if (result.length == 5) { //lost
alert('lost');
} else if ( result.length == 4) { //won
alert('won');
//document.getElementById("bet-bt").click();
} else {
alert('something is wrong' );
///document.getElementById("bet-bt").click();
}
}
</script>