gpt4 book ai didi

javascript - 我收到未捕获的类型错误 : Cannot set property 'onclick' of null?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:43:55 24 4
gpt4 key购买 nike

<分区>

我收到未捕获的类型错误:未捕获的类型错误:无法设置 null 的属性“onclick”

<!DOCTYPE html>
<html>
<head>
<title>dice app</title>
<script src="widget.js"></script>
</head>
<body>
<button id="button">Roll Dice</button>
</body>
</html>

js代码:

var button = document.getElementById("button");

button.onclick = function() {// error
var print = dice.roll();
printNumber(print);
};

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com