2009-09-08 63 views

回答

8

參考jQuery的腳本,然後燈箱腳本在HTML document.Like所以,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
<script type="text/javascript" src="source-of-jquery.js"></script> 
<script type="text/javascript" src="source-of-lightbox-plugin.js"></script> 
<script type="text/javascript" src="source-of-script-with-your-jquery-code-in.js"></script> 
</head> 
<body> 

.... 

,那麼你將需要相應地使用燈箱。例如,在source-of-script-with-your-jquery-code-in.js

$(function() { 
$('#gallery a').lightBox({fixedNavigation:true}); 
}); 

結合的燈箱插件每個<a>元素是元素的id爲孩子gallery

編輯:

jQuery是隻是一個JavaScript框架(雖然是一個很好的框架)。如果您開始進行前端Web開發之旅,我會建議將JavaScript與jQuery結合使用,因爲它是框架的構建塊,並且可以幫助您瞭解它如何更好地工作。這裏有一些資源,讓你開始

4

你需要引用的JavaScript文件在您的HTML已經下載了jQuery

<script type="text/javascript" src="/path_to_js_files/jquery.js"></script> 

您還需要添加參考到您爲Lightbox插件下載的js文件。

有一個關於jQuery的初學者教程here