1
이것은 몇 가지 알림과 첫 번째 게시물을 제외하고 필자가 작성한 첫 번째 자바 스크립트입니다. 그래서 HTML 페이지와 외부 자바 스크립트 파일을 만들었습니다. 두 파일은 같은 디렉토리에 있으며 각 파일의 철자를 검사했습니다. 여기 자바 스크립트 외부 파일이 올바르게 연결되지 않습니다.
는 HTML 코드입니다 :<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" onclick="divGrow">Grow</button>
<button id="button2" onclick="divColor">Blue</button>
<button id="button3" onclick="divFade">Fade</button>
<button id="button4" onclick="divReset">Reset</button>
<script type="text/javascript" src="javascript.js"></script>
</body>
여기에 자바 스크립트 파일입니다
function divGrow() {
alert("This grows the box");
document.getElementById("box").style.width = "300px";
document.getElementById("box").style.height = "300px";
}
function divColor() {
alert("This changes the Box to Blue");
document.getElementById("box").style.backgroundColor = "Blue";
}
function divFade() {
alert("This fades the box");
document.getElementById("box").style.opacity = ".5";
}
function divReset() {
alert("This resets the box")
document.getElementById("box").style.backgroundColor = "Orange"
document.getElementById("box").style.width = "150px";
document.getElementById("box").style.height = "150px";
document.getElementById("box").style.opacity = "0";
}
내가 다른 링크를 실종? 자바 스크립트 코드를 작동 시키려면?
[콘솔 확인] (http://stackoverflow.com/documentation/javascript/185/hello-world/714/using-console-log)에서 오류가 있습니까? –