所以,当玩家的分数达到 5 时,我希望在我的页面上出现一个重置按钮。但我似乎无法让它出现。
if (Score == 5) {
btnQuestion.disabled = true;
txtQuestionFeedback.innerText = "Correct! \n Congratulations, you've got 5 stars!";
imgScore5.src = "Images/StarOn.gif";
document.getElementById(btnReset).innerHTML = btnReset;
}
最佳答案
尝试以下操作:
1) 像这样将按钮元素插入 DIV 中以便于阅读
<div id="resetButtonDiv">
<button id="resetButton"></button> <!-- here goes your button config -->
</div>
2)用JS把样式改成这样
<script>
function showResetButton() {
document.getElementById("resetButton").style.display = "none";
if (Score == 5) {
// Replace "Score" with your variable or element
document.getElementById("resetButton").style.display = "show";
}
}
showResetButton()
</script>
关于javascript - 如何在某些要求后出现重置按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58767498/