본문 바로가기

퍼블리싱/Debuging

Uncaught SyntaxError: Unexpected token ILLEGAL

구문상 에러가 전혀 없는데 신텍스에러라고 뜨는 경우가 있다.

Uncaught SyntaxError: Unexpected token ILLEGAL 


// 에러난 구문

$("<div><a href='"+portfolio[i].href+"'>
            <img src='"+portfolio[i].image+"' alt='"+portfolio[i].title+"' />"+

string  " "안에 공백이 들어가면 생기는 에러이다.


// 수정된 구문

$("<div><a href='"+portfolio[i].href+"'><img src='"+portfolio[i].image+"' alt='"+portfolio[i].title+"' />"+

이렇게 공백을 없애주면 에러가 해결된다.