2010-01-27 58 views
0

爲什麼沒有這個jQuery工作,根據螢火蟲沒有的JavaScript線正在達到:爲什麼不是這個google.load,google.setOnLoadCallback腳本工作?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <script type="text/javascript" 
     src="http://www.google.com/jsapi"></script> 
     <script type="text/javascript"> 
      google.load("jquery", "1.4.0"); 
      google.setOnLoadCallback(function() { 
       $("p").css("background-color","red"); 
      } 
     </script> 
    </head> 
<body> 
    <p>test</p> 
</body> 
</html> 

回答

4

你有缺失右括號)

google.load("jquery", "1.4.0"); 
google.setOnLoadCallback(function() { 
    $("p").css("background-color","red"); 
}); // <--- Here 
+0

+1在錯誤的文檔看着開始並認爲API密鑰也是必需的。刪除我的答案,因爲你是所有需要:) – 2010-01-27 06:06:49

+0

非常感謝道格! – CMS 2010-01-28 00:04:24