나는 HTML/JavaScript로 시작하고 있으며 간단한 질문이 있습니다. 별도의 스크립트 소스에서 js 함수를 호출하려고 시도하지만 약간의 문제가 있습니다. 내 기능 스크립트 (date_button_function.js)를 읽이 기능을 호출하기 위해 리모컨 파일에서로드 된 JavaScript 기능 호출
function displayDate()
{
document.getElementById("date").innerHTML=Date();
}
, 내 코드는 다음과 같습니다
:<html>
<head>
<script type="text/javascript" src="date_button_functoin.js"></script>
<body>
<h1>Testing the Date</h1>
<p id="date">Click below to see the date.</p>
<button type="button" onclick="displayDate()">Display Date</button>
</body>
</html>
나는 실제로 HTML 스크립트에서 displayDate
기능을 쓸 때 , 그것은 잘 실행됩니다. 그러나 함수를 호출 할 때 작동하지 않습니다. 누군가 내 구문 오류를 알릴 수 있다면 좋을 것입니다.
src에 'date_button_function.js'라고 써야하나요? – Ivan