我無法讓我的簡單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' –