我无法让我的简单JavaScript代码运行,我在考虑代码可能无法正确链接。你会友善地看一看吗?下面是HTML代码:将Javascript链接到HTML
<!DOCTYPE html>
<html>
<head>
<title>Jiggle Into JavaScript</title>
<script type="text/javascript" src="javascript.js"></script>
<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> -->
</head>
<body>
<p>Press the buttons to change the box!</p>
<div id="box" style="height:150px; width:150px; background-color:orange; margin:25px"></div>
<button id="Button1">Grow</button>
<button id="Button2">Blue</button>
<button id="Button3">Fade</button>
<button id="Button4">Reset</button>
</body>
</html>
而这里的JS代码:
document.getElementById("Button1").addEventListener("click", function(){
document.getElementById("box").style.height=200%;
});
感谢您的帮助,您可以提供!
您需要加载JS ** **后用ID的元素'Button1' –