Develop
[Error] Uncaught TypeError: back is not a function at HTMLInputElement.onclick 본문
웹 개발/Error
[Error] Uncaught TypeError: back is not a function at HTMLInputElement.onclick
개발 기록 2024. 2. 15. 17:39
오류
Uncaught TypeError: back is not a function at HTMLInputElement.onclick
위와 같은 오류가 났다
이유를 찾아보니
<input type="button" id="back" class="btn_gray" value="돌아가기" onclick="back();">
input태그의 id도 back이고 onclick event 발생시 실행되는 함수명도 back이라서 난 오류이다
즉 id와 함수명이 같으면 안된다
//뒤로가기
function back(){
history.back();
}
그래서 함수명을 backTo로 바꾸고 input 태그의 onclick 이벤트 실행시 동작하는 함수명도 바꿨다
<input type="button" id="back" class="btn_gray" value="돌아가기" onclick="backTo();">
<script>
//뒤로가기
function backTo(){
history.back();
}
</script>
참고한 글
[html 오류] id와 함수명 같을때 (form태그, input태그) :: 꾸준2 (tistory.com)
[html 오류] id와 함수명 같을때 (form태그, input태그)
- form 태그안에 input 태그에서 id와 함수명이 같은경우 오류가 발생한다. // Uncaught TypeError: short is not a function at HTMLInputElement.onclick // html // javascript function short() { console.log('hi'); } 해결 방법 1. 클릭
rnwns2.tistory.com
'웹 개발 > Error' 카테고리의 다른 글
오류 났을 때 스택트레이스 읽기 방법과 중요성 (0) | 2025.01.06 |
---|---|
스프링부트 새프로젝트 생성시 나는 오류 (0) | 2024.12.31 |
[Error] mapper에서 getter, setter 메서드 호출 오류 (0) | 2024.03.09 |
[Error] class/typealias not found : Alias 못찾는 오류 (0) | 2024.03.08 |