您可以使用下面的代碼(實時預覽http://codepen.io/larryjoelane/pen/KVGJMp):
將代碼放在一個JavaScript文件,並已加載jQuery和循環2 JavaScript文件後加載它。
例(請將您的收盤</body>
標籤在此之前就在您的HTML文件:
<!--Script Tags-->
<script src="pathtoyourjqueryfile"></script>
<script src="pathtoyourcycle2file"></script>
<!--place the code I provided in here-->
<script src="pathtoyouraddedjavascript"></script>
,因爲你首先需要加載的jQuery然後加載循環2插件,然後最後加載代碼的順序很重要。我公司提供
JQuery的:
//array of links for each slide
var links = [
"http://google.com",
"http://google.com",
"http://google.com",
"http://google.com",
];
$(document).on("click",".cycle-slideshow img",function(){
//store the index(1 is subtracted because arrays begin with 0)
//and index will return 1,2,3,4 etc.
var index = $(this).index() - 1;
//navigate to the link
window.location = links[index];
});