javascript - HTML : Photo swipe is not workling

标签 javascript html css

我正在尝试为滑动图像实现 photoswipe.js,但滑动不起作用。

<script type="text/javascript" src="js/klass.min.js"></script>
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="js/code.photoswipe-3.0.4.min.js">       </script>


 <script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, true);

function onDeviceReady() {
   // related functions
     alert("check");
   $("#Gallery a").photoSwipe();
} 
(function(window, PhotoSwipe){

    document.addEventListener('DOMContentLoaded', function(){

        var
            options = {},
            instance = PhotoSwipe.attach(    window.document.querySelectorAll('#Gallery a'), options );

    }, false);


}(window, window.Code.PhotoSwipe));

</script>

正文

<ul id="Gallery" class="gallery">
<li><a href="img/img1.jpg"><img src="img/img1.jpg" rel="external" alt="" />   </a></li>
<li><a href="img/img2.jpg"><img src="img/img2.jpg" rel="external"  alt="" /></a></li>

</ul>

谁能告诉我哪里出错了。 提前致谢

最佳答案

我认为你的 cordova 加载在 DOM 加载之前完成,所以添加 document.addEvenListener("deviceready", onDeviceReady, true);线 内部文档加载功能。

关于javascript - HTML : Photo swipe is not workling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30994364/

相关文章:

javascript - 组合 'var' 语句

javascript - AJAX 'success' 在 IE 中 AJAX 执行之前调用

html - 虚线没有包围预期的部分(最近的工作经历)——错在哪里?

html - 如何将输入栏中的箭头向右移动?

javascript - 加载页面时需要保持 collapsible 1 打开

javascript - 使用 JS 更改基于 URL 的 <h1>

javascript - 在 Paper.js 中适合页面缩放后,光栅图像偏离中心

html - 如何更改焦点上的边框颜色?

html - 聊天网页设计中的滚动问题

html - 无法使用 bootstrap 4 作为框架使 div 内容正确对齐