我正在尝试使用jQuery.Lighbox库,但无法找到lightBox方法。
我做了什么:
包括jquery.lightbox.js(立即在jquery之后):
<html lang="en">
<head>
<meta charset="utf-8" />
<link href="/Content/site.css" rel="stylesheet"/>
<link href="/Content/jquery.lightbox.css" rel="stylesheet"/>
<script src="/Scripts/modernizr-2.5.3.js"></script>
<script src="/Scripts/jquery-1.7.1.js"></script>
<script src="/Scripts/jquery.lightbox.js"></script>
...
<head>
在我体内,我正在将灯箱代码连接到html元素:
<body>
<script type="text/javascript">
$(function () {
try
{
$('#gallery a').lightBox(); // Select all links with lightbox class
}
catch (err) {
var txt = "";
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
});
</script>
并且非常期待js代码抛出错误:
此页面出错。错误说明:对象[对象 对象] 没有方法'lightBox'单击确定继续。
我是jQuery的新手,所以如果你能给我一个提示我做错了什么以及如何解决它。
谢谢。
修改
已解决:原来jquery.js已经包含两次,而且它隐藏了jquery.lightbox函数。
答案 0 :(得分:1)
Object [object Object]没有方法'lightBox'
这意味着没有找到lightBox方法,这意味着灯箱js没有正确加载..检查出来...查看源..并确保你的路径是正确的