我是 web 开发的新手,实际上我对 js 几乎一无所知。
我正在尝试“禁用” 3 个按钮,然后单击它们 5 秒钟。我的 ID 是正确的,但它只给我这个错误stop和restart按钮/i。它适用于play.
Error that I got -> Uncaught TypeError: Cannot read property 'style' of null
at actionButtonfuction (Website:145)
at HTMLButtonElement.onclick (Website:179)
在单个函数中可以设置多少个项目的样式是否有任何限制?
<script>
function actionButtonfuction() {
document.getElementById("actionButton").disabled = true;
document.getElementById("play").style.color = "#808080";
document.getElementById("stop").style.color = "#808080";
document.getElementById("restart").style.color = "#808080";
setTimeout(function() {
document.getElementById("actionButton").disabled = false;
document.getElementById("play").style.color = "#16a72d";
document.getElementById("stop").style.color = "#db3224";
document.getElementById("restart").style.color = "#1b6ec2"
}, 5000);
//console.log("button clicked");
}
</script>
<button class="console_button" onclick="actionButtonfuction()" id="actionButton" asp-action="">
<i id="stop" class="fa fa-stop"></i>
</button>
<button class="console_button" onclick="actionButtonfuction()" id="actionButton" asp-action="">
<i id="play" class="fa fa-play"></i>
</button>
<button class="console_button" onclick="actionButtonfuction()" id="actionButton" asp-action="">
<i id="restart" class="fa fa-refresh"></i>
</button>
翻翻过去那场雪
吃鸡游戏
慕尼黑8549860
相关分类