我正在使用 javascript/JQuery 运行这个 html 文档,在回答提示后,什么也没有发生。似乎附加功能不起作用。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>
Rock Paper Scissors
</title>
<script>
var userChoice = prompt("Do you choose rock, paper, scissors lizard or spock?");
userChoice = userChoice.toLowerCase();
var computerChoice = function(){
var choices = ["rock", "paper", "scissors", "lizard", "spock"];
var random = Math.random();
var loop = true;
while (loop){
i = 0.2;
j = 0;
if (random <= i){
var choices = choices[j]
var loop = false;
}
else {
i = i +0.2;
j ++;
}
}
return choices;
};
$(document).ready(function(){$("body").append(userChoice);});
$(document).ready(function(){$("body").append(computerChoice());});
</script>
</head>
<body>
</body>
</html>