<html>
<head>
<title>Document</title>
<style>
table { border-collapse: collapse;}
table tr td { border:1px solid red; width:70px; height:70px}
</style>
<script>
function catch(){
alert("safsf");
}
</script>
</head>
<body>
<h3>마우스 클릭 연습</h3>
<hr>
<table>
<tr>
<td><img src="예제의 미디어 파일들\9장\media/strawberry.png" onclick="catch()" width="70px;" height="70px;"></td>
<td><img src="" onclick="catch()"></td>
이미지태그에 onclick 를 주고 우선 제대로 동작하는지 테스트를 해보고있는데
뭐가 잘못됐길래 onclick에 전혀 반응을 안하는건가요?
script 태그에 alert 이나 document.wirte 나 innerHTML 로 넣어봐도 다 반응이 없네요ㅠ
자바스크립트에도 자바나 C++과 같이 예외처리를 위한 다음 구조를 지원합니다.
try {
tryStatements
}
catch(exception){
catchStatements
}
finally {
finallyStatements
}
함수 이름을 catch 대신 다른 것으로 수정하면 됩니다.
그리고 오류는 아니지만 HTML5 문서임을 나타내기 위해
HTML 페이지 첫 줄에 <!doctype html>를 넣도로 하세요.