這是一個有點棘手的工作,我的建議是按照指示,並從這裏發現了GitHub庫提供的代碼:https://github.com/cjboco/cj-image-video-previewer
而且要記住,正確的jQuery庫和CJ圖片視頻預覽庫。在你提供的代碼中,我沒有看到JQuery庫的源代碼,這可能是問題的一部分。
然後如果從在GitHub上提供的例子去,並儘量減少代碼,這是一個簡單的例子,工作:
<!doctype html>
<!--[if lt IE 7 ]><html lang="en" class="no-js ie6"><![endif]-->
<!--[if IE 7 ]><html lang="en" class="no-js ie7"><![endif]-->
<!--[if IE 8 ]><html lang="en" class="no-js ie8"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="no-js ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style type="text/css">
.Videos {
display: block;
height: auto;
width: 100%;
}
.Videos div.thumbnail {
border: 1px solid #999;
display: block;
float: left;
height: 110px;
margin: 0px 10px 10px 0px;
overflow: hidden;
position: relative;
width: 160px;
}
.Videos div.thumbnailBig {
border: 1px solid #999;
display: block;
float: left;
height: 240px;
margin: 0px 10px 10px 0px;
overflow: hidden;
position: relative;
width: 320px;
}
</style>
</head>
<body>
<div class="Videos clearfix">
<div id="preview_01" class="thumbnail">
<img src="https://placehold.it/160x110" alt="test image" width="160" height="110">
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://www.cjboco.com/projects/cj-image-video-previewer/1.1.1/demo/jquery.cj_image_video_previewer.js"></script>
<script>
(function($) {
'use strict';
$('#preview_01').cjImageVideoPreviewer({
images: [
'https://placehold.it/160x111',
'https://placehold.it/160x112'
]
});
}(jQuery));
</script>
</body>
</html>
希望這有助於!
你的瀏覽器控制檯有任何錯誤嗎? –
我當時是與其他代碼相關的,現在我儘可能簡化所有的代碼。只是讓這個工作,所以現在我沒有任何錯誤。 – simona