1
我有一個彈出的提示,詢問「你想玩嗎」,如果答案是真的,它會運行一些代碼。但是當你點擊「是」後,我希望按下一個按鈕,並且我的代碼繼續運行而不用等待它被按下。等待點擊按鈕才能繼續
這裏是我有,如JavaScript:
var start = confirm("Would you like to Play?");
var plays = 0;
var playerScore = 0;
var computerScore = 0;
var userChoice = ""
function choose(buttonChoice) {
userChoice = buttonChoice;
}
while(start) {
var pScoreDiv = document.getElementById('pScore');
pScoreDiv.innerHTML = playerScore;
var cScoreDiv = document.getElementById('cScore');
cScoreDiv.innerHTML = computerScore;
console.log(playerScore);
console.log(computerScore);
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
}
<button onClick="choose('rock')">Rock</button>
<button onClick="choose('paper')">Paper</button>
<button onClick="choose('scissors')">Scissors</button>
做的是使你的遊戲的的jsfiddle(https://jsfiddle.net/)和共享的鏈接,使人們對這裏可以一看的最好的事情在它並正確地爲您調試它。 – Giuseppe
好吧現在就試試:) –
https://jsfiddle.net/3cuwnafz/ –