2012-09-03 27 views
-1

我真的很困惑,我已經讀了很多次代碼,但我不明白爲什麼這是錯誤的。我已經減少它歸結爲它的最簡單的形式(...條取代的與alert(); S),我仍然得到這個錯誤:意外的開放式大括號?

$(document).ready(function() { 


$(".foo").hover(function() { 
    ... 
},function() { 
    ... 
}); 

${"#bar"}.click(function() { <---- Uncaught SyntaxError: Unexpected token { 
    ... 
}); 


}); 
+0

$ {「#bar」}。click -^that must be a()no? – codemonkey

+0

有一個'{'而不是'(' – DrColossos

+0

Gah,我是個白癡。 – fredley

回答

5

嘗試更換:

${"#bar"} 

$("#bar") 
1

應該不是:

$("#bar").click(function() { 

你有大括號而不是#bar左括號。

0
Try this: 

$(document).ready(function() { 


$(".foo").hover(function() { 
    ... 
},function() { 
    ... 

}); 

$("#bar").click(function() { <---- Uncaught SyntaxError: Unexpected token { 
    ... 
}); 


});