【问题标题】:object has no method lightbox对象没有方法灯箱
【发布时间】:2012-08-02 00:57:10
【问题描述】:

我正在尝试将lightbox 应用于我的div

我已经加载了 jquery 文件和 lightbox.js,但仍然得到 Object has no method lightBox 错误消息。我想知道是否有人可以帮助我解决这个问题。非常感谢!

<link rel="stylesheet" href="css/basic/basic.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="css/basic/jquery.lightbox-0.5.css" type="text/css" media="screen"/>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js'></script>
<scirpt type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
<script type='text/javascript'>
   $(document).ready(function(){   

    $('#image img').lightBox();
})
</script>


<div id='image'>

/**/these images are generated from ajax call. not sure if it's relevant.**


<img src='a.jpg'/>
<img src='b.jpg'/>
<img src='c.jpg'/>


 </div>

【问题讨论】:

  • 我爱的人只是给我-1而不告诉我原因。
  • 你如何确定js/jquery.lightbox-0.5.js 已加载?如果已加载,您应该不会收到错误 object has no method lightBox
  • @Juan 我在我的 html 脚本中添加了。还有其他方法可以测试吗?
  • 使用浏览器中的检查器查看脚本是否未加载,或尝试直接点击脚本的 url
  • $('img').lightBox(); 会发生什么?顺便说一句,我认为您必须在加载图像后初始化lightbox,在ajax回调中,尝试lightbox().init()(ro initialize(),start()......我不知道正确的语法)。跨度>

标签: jquery lightbox


【解决方案1】:

就我而言,我发现 JQuery 和 $ 之间存在冲突

准备好更改文档是解决方案

 <script type='text/javascript'> 

    $(document).ready(function(){   

        $('#image img').lightBox(); }) 

 </script>

【讨论】:

    【解决方案2】:

    在我的情况下,问题是 ftp 软件,它没有正确上传脚本。尝试将源文件从原始文件“jquery.lightbox-0.5.js”手动复制/粘贴到您的服务器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多