2010-01-27 59 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