[在此处输入图像描述] [ 1]当我在Atom IDE中运行代码时,会出现此错误:
ReferenceError:未定义文档
我该如何解决?
JS:
var images1 = "images/dice"+ randomNumber1 +".png";
document.querySelector(".dice .img1").setAttribute("src",images1);
HTML:
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Dicee</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Refresh Me</h1>
<div class="dice">
<p>Player 1</p>
<img class="img1" src="images/dice6.png">
</div>
<div class="dice">
<p>Player 2</p>
<img class="img2" src="images/dice6.png">
</div>
</div>
<script src="index.js" charset="utf-8"></script>
</body>
<footer>
www ? App Brewery ? com
</footer>
</html>