[Solved] Javascript uncaught syntaxerror unexpected identifier error


In this line

htmlStr +=  '<a id="searchResult'+i+'" href="https://stackoverflow.com/questions/29555599/javascript:liveSearch("+arrOfSuggestText[i]+')" > '+arrOfSuggestText[i]+'</a>';

and concrete here '" href="https://stackoverflow.com/questions/29555599/javascript:liveSearch("+arrOfSuggestText[i]+')" > ' you try create calling function, but if you see value of this string, for arrOfSuggestText[i] == 'qwe' you can see something like

href="https://stackoverflow.com/questions/29555599/javascript:liveSearch(qwe)"

and browser raise error what you get on qwe.

So you need just add quotes around like

'" href="https://stackoverflow.com/questions/29555599/javascript:liveSearch(\"'+arrOfSuggestText[i]+'\')" > '

1

solved Javascript uncaught syntaxerror unexpected identifier error