我如何将jquery代码放在html文档中?(灯箱)

Kev*_* Li 7 jquery

如何让jquery显示在现有的html文档中.主要是jquery灯箱插件

编辑:?我怎么参考?

Rus*_*Cam 8

引用jQuery脚本,后跟html文档中的lightbox脚本.就像这样,

<!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>

....
Run Code Online (Sandbox Code Playgroud)

那么你需要相应地使用灯箱.例如,在source-of-script-with-your-jquery-code-in.js

$(function() {
 $('#gallery a').lightBox({fixedNavigation:true});
});
Run Code Online (Sandbox Code Playgroud)

将lightbox插件绑定到每个<a>元素,该元素是具有id的元素的子元素gallery

编辑:

jQuery只不过是一个JavaScript框架(虽然是一个很棒的框架).如果您正在开始前端Web开发之旅,我建议将JavaScript与jQuery结合使用,因为它是框架的构建块,并将帮助您了解它如何更好地工作.这里有一些资源可以帮助您入门