본문 바로가기
개발기록

Error about String type parameter - Uncaught SyntaxError: Unexpected end of input

by 떤떤 2021. 3. 3.

미리보기 사진 태그를 지울 onclick 이벤트의 함수 removeImg()는 img태그의 class이름을 매개변수로 받아와서

게시글 수정일 때의 미리보기인지 게시글 업로드 할 때의 미리보기인지 확인하려고 class 이름을 매개변수를 받은건데

그냥 imgPreview로 썼을 때 Uncaught SyntaxError: Unexpected end of input 오류가 발생했다.

 

 

 

수정 전 before

const imgClassName = "imgPreview";
html += `<button type="button" class="close-btn" aria-label="Close" onclick="removeImg(imgPreview)" />`

 

수정 후 after

const imgClassName = "imgPreview";
html += `<button type="button" class="close-btn" aria-label="Close" onclick="removeImg('` + imgPreview + `')" />`