[Solved] Syntaxerror: Unexpected Token: String Literal
Solution: You are seing this error because you need to properly escape your code when using doublequotes or single quotes within parameters.
Question: I am getting an error in my Firefox Console. The error is:
SyntaxError: unexpected token: string literal
Solution: After looking at the code, you must escape your string using the proper method.
Example:
<button onclick="$(".myClass").hide()">Click Me To Hide</button>
the correct way is to use single quotes inside double quotes.
<button onclick="$('.myClass').hide()">Click Me To Hide</button>
Sometimes you may have complicated code where you are using something like this:
$('.myDiv').append('$('.myClass').hide()">Click Me To Hide</button>');
The correct way to escape example2:
$('.myDiv').append('$(\'.myClass\').hide()">Click Me To Hide</button>');
Hope that helps.