javascript - 如何在某些要求后出现重置按钮?

标签 javascript

所以,当玩家的分数达到 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/

相关文章:

javascript - 设置请求 header jQuery Ajax

javascript - 如何使用 Apollo Client 有效地批处理 GraphQL 突变?

javascript - 单击按钮后,在打开 url 之前等待

php - 如何访问 json_encode 结果?

javascript - Shopify 布鲁克林主题 : changes not reflected

javascript - 错误类型错误 : Cannot read property 'value' of undefined in Angular 8

javascript - jQuery - 显示div的出现次数

javascript - 如何在不需要等待的情况下使用 jquery deferred

javascript - 在codeigniter中将数据从javascript传递到php文件

javascript - 页面调整大小后滑动切换错误 - jQuery