자바 스크립트를 가르치려고합니다. 그러나 다음 코드가 작동하지 않는 이유를 알 수 없습니다. 어떤 아이디어?표시 날짜가 자바 스크립트
<!DOCTYPE html>
<html>
<body>
<p> Click the button to display the date</p>
<button onclick="showDate()">HIT ME</button>
<script>
function displayDate()
{
document.getElementById("test").innterHTML=displayDate();
}
</script>
<p id="test"></p>
</body>
복사 및 잘못, 여기에 실제 코드 붙여 넣기 :
<!DOCTYPE html>
<html>
<body>
<p> Click the button to display the date</p>
<button onclick="showDate()">HIT ME</button>
<script>
function showDate()
{
document.getElementById("test").innterHTML=Date();
}
</script>
<p id="test"></p>
</body>
에 오타가? 'onclick' 함수의 이름은 아래의'script' 태그에서 작성한 함수의 이름과 동일하지 않습니다. 이 코드에는 많은 문제점이 있습니다. 어떻게 당신은 자바 스크립트를 배우려고합니까? – MattDiamant
방금 [재귀 함수] (http://www.codecademy.com/courses/javascript-lesson-205/0/1)를 수행했습니다. 함수가 _itself_를 호출하여 무한 루프가됩니다. ->'displayDate()'는 실제로 _called_되지 않으므로 실행되지 않습니다. – mathielo
onclick = "showDate()"=> 어디 함수입니까? showDate() {...} ?? – frenchie