2010-05-23 93 views
1

有沒有人知道這個谷歌代碼是如何工作的?jquery谷歌鏈接

我有以下幾點:

<!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> 
    <title>My Google AJAX Search API Application</title> 
    <script src="http://www.google.com/jsapi?key=blahblahblah" type="text/javascript"></script> 
    <script language="Javascript" type="text/javascript"> 
    google.load("jquery", "1"); 
    google.load("jqueryui", "1"); 
    </script> 
    </head> 
    <body> 
    <div class="ui-state-highlight"> 
    hello world 
    </div> 
    </body> 
</html> 

然而<div></div>應顯示與世界您好錯誤對話框。但它沒有顯示紅色的背景,因此用戶界面不工作...

我在這裏做了什麼錯?

回答

5

您還需要樣式表,如果你想要的造型,這樣的:(!一定得更新的版本號)

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css"> 

這是基礎(灰色)的主題,there are others

除非你需要google.load其他的東西,你可以直接包含腳本,值得看看this question的優點/劣勢使用google.load()

加載它們直接是這樣的:應顯示

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css"> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script> 
+0

感謝名單,使得很多的意義地獄:)不像谷歌的網頁...你能不能幫我找到位置爲了用戶?的jquery,因爲那裏只有jquery核心...還有我不能把最新?而不是版本號或類似的東西:) – Val 2010-05-23 14:40:07

+0

@Val -Google在這裏有一個頁面:http://code.google.com/apis/ajaxlibs/最新的,你可以把'/1 /'代替最新版本1的'/ 1.4.2 /',或者最新的1.4.x版本的'/ 1.4 /',這是否合理? – 2010-05-23 14:44:01

+0

使用最新的更新版本並不一定好,您的某些內容可能會中斷。我個人喜歡只使用1.8.1,然後在必要時進行更新。 – Derek 2010-05-23 15:29:03

0

的Hello World,但由於該類用戶界面狀態,hightlight是無處可尋,世界你好只是顯示爲純文本。

0

它的工作原理採用<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css">

你也可以推出自己的風格在這裏

​​