Reputation: 2979
I get this error when i try to call this function in Chrome 16.0.912.77 m:
function fade(e){
if(op > 0){
op -= 0.01;
document.getElementById(e).style.opacity = op;
window.setTimeout("fade(\""+e+")\"", 10);
}
}
It's a simple function which fade a element on my page out. I read that the error appears when i forgett a }-bracket, but i closed all..
Any ideas?
Upvotes: 0
Views: 6851
Reputation: 146460
If you inspect this in your favourite JavaScript console:
var e = "foo";
alert("fade(\""+e+")\"");
... you'll see this:
fade("foo)"
Use on your favour the fact that JavaScript allows both single and double quotes:
var e = "foo";
alert('fade("' + e+ '")');
Or, even better, call setTimeout() with a function reference instead of a string (find some examples in the linked page).
Upvotes: 1
Reputation: 8459
window.setTimeout("fade(\""+e+"\")", 10);
You have the closing quote and closing parentheses swapped.
Upvotes: 2