Your code is working fine. Here's a live demo: Click here.
You need to check the line number where you get this error.
edit: I just thought. If your html markup has an error (possibly a closed text area), the script can be evaluated as a script tag, not text. Check it. Here is a live example of an html error that will cause your problem. Press here.
Update: I believe I know exactly what the real problem is. Other posts recommend that you avoid '<' and '>', but this is only necessary if the javascript you use is actually located in the html file (or html generated by the server) and not in the js file where he belongs. In the js file, this, of course, will be the line as you wrote it, but the html file sees it as markup, although it is not intended. This is an example of why you should follow best practices and store javascript in a js file.
source share