尝试使用jQuery.LightBox时出现此错误:
Uncaught TypeError: Object [object Object] has no method 'lightBox'
这是一个实例(在div中重建表设计,不要讨厌。):
http://www.builderpreviews32.com/photos.php
是的,jQuery文件是在jQuery.LightBox文件之前引用的。
这是我的代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta name='keywords' content=''>
<meta name='description' content=''>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<link href="/common/styles/global.css" rel="stylesheet" type="text/css" />
<link href="/common/styles/lightbox.css" rel="stylesheet" type="text/css" />
<script src="/common/scripts/jquery-1.10.2.min.js"></script>
<script src="/common/scripts/lightbox-2.6.min.js"></script>
<body>
<div id="wrapper">
<div id="header">
<a href="/"><img src="/common/images/lgo_lake.jpg" alt="Riss Lake Logo" /></a>
<div id="nav">
<nav>
<a href="/about.php">About Riss Lake</a>
<a href="/developer.php">Developer</a>
<a href="/developer.php">Communities</a>
<a href="/awards.php">Awards</a>
<a href="/areamap.php">Area Map</a>
<a href="/developer.php">Inventory</a>
<a href="/photos.php">Photos</a>
<a href="/builders.php">Builders</a>
<a href="/developer.php">Contact Us</a>
<a href="/areainfo.php">Area Information</a>
</nav>
</div> <!-- End Nav -->
</div> <!-- End Header -->
<div id="body">
<!--MODULE:image_gallery.php|CACHE:main_photos-->
<div class="lightbox">
<a href="/images/uploaded/115747639443725_poolside_sm.jpg"><img src="/images/uploaded/thumb_115747639443725_poolside_sm.jpg" alt=""
width="150"
class="photo_edge" /></a>
<a href="/images/uploaded/115747639443725_poolside_sm.jpg"><img src="/images/uploaded/thumb_115747639443725_poolside_sm.jpg" alt=""
width="150"
class="photo_edge" /></a>
<a href="/images/uploaded/115747639443725_poolside_sm.jpg"><img src="/images/uploaded/thumb_115747639443725_poolside_sm.jpg" alt=""
width="150"
class="photo_edge" /></a>
<a href="/images/uploaded/960211759433150_002.jpg"><img src="/images/uploaded/thumb_960211759433150_002.jpg" alt=""
width="150"
class="photo_edge" /></a>
</div>
<script type="text/javascript">$(function(){$('.lightbox a').lightBox();});</script>
</div>
<div id="footer">Copyright © 2003. <a href="/privacy.php">Privacy Policy</a> | <a href="/terms.php">Terms of Use</a></div>
</div> <!-- End Wrapper -->
</body>
</html>
答案 0 :(得分:1)
解决问题的方法很少
确保您的脚本标记已关闭。
我最初的猜测是,它必须是由于脚本没有正确排序,如果正确包含脚本并在使用浏览器调试器进行调试时加载。我早些时候也遇到过这个问题。
祝你好运,并告诉我它是否成功。
答案 1 :(得分:0)
您应该将脚本包含在头部
中<link href="/common/styles/global.css" rel="stylesheet" type="text/css" />
<link href="/common/styles/lightbox.css" rel="stylesheet" type="text/css" />
<script src="/common/scripts/jquery-1.10.2.min.js"></script>
<script src="/common/scripts/lightbox-2.6.min.js"></script>