Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  25] [ 4]  / answers: 1 / hits: 29829  / 12 Years ago, sat, march 31, 2012, 12:00:00

This function gives me the following error:




SyntaxError: Invalid character 'u8203'




All looks good to me,



function changeColumnWidth() {
var w = Math.random() * 200+80;
$('#menu').css(width, w+px);
}​


can someone spot the error?


More From » jquery

 Answers
23

It's a character after the closing curly brace:



I copy-pasted your code in Firefox' console, postfixed with a undefined method invocation:



'function changeColumnWidth() {
var w = Math.random() * 200+80;
$('#menu').css(width, w+px);
}​'.l(); /* .l() triggers a TypeError, since it's not defined */


A TypeError (undefined) shows up, which includes the parsed (escaped) code:



TypeError: function changeColumnWidth() { var w = Math.random() * 200+80; $('#menu').css(width, w+px);}u200B.l is not a function.

                                 ^^^^^^ Here's the error.



Now, the troublemaker is found. To fix it, open your code in a text editor, and remove the invisible character. This character can be detected by walking through all characters using the arrow keys.


[#86490] Friday, March 30, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antoinette

Total Points: 206
Total Questions: 99
Total Answers: 95

Location: Guam
Member since Tue, Nov 29, 2022
2 Years ago
;