我是Java语言的新手,请尝试对投资组合网站实施下一个/上一个(循环)按钮。我设法使“下一个”按钮正常工作,但是找不到正确的上一个按钮的方法。我已经尝试了一切,但最终没有解决方案。
等等,在我的HTML部分中,我有那些类,这些类可以根据菜单+按钮来加载其他文件:
<button class="paginate pt-trigger2"><i>PREVIOUS</button>
<button class="paginate pt-trigger3"><i>NEXT</button>
<div class="pt-page pt-page-2" id="cadrage"><div class=contiennement> </div></div>
<div class="pt-page pt-page-3" id="cadrage"><div class="contiennement"> </div></div>
在Jquery方面,这是我包含的脚本:
<script>
$(document).ready(function(){
var arr = ["home.php","photo.php","websites.php","identity.php","illustration.php","about.php"];
var index = 1;
var pagess = [".pt-page-1",".pt-page-2",".pt-page-3",".pt-page-4",".pt-page-5",".pt-page-6"];
$('.pt-trigger2').click(function(){
$(".pt-page").html("");
$('.pt-page').fadeIn(500);
$(pagess[index]).load(arr[index]);
index = (index-1) % arr.length ;
});
$('.pt-trigger3').click(function(){
$(".pt-page").html("");
$('.pt-page').fadeIn(500);
$(pagess[index]).load(arr[index]);
index = (index+1) % arr.length ;
});
});
<script>
如此一来,无论我在网站上的什么地方,一切都可以正常工作,上一个按钮将加载.pt-page-2(photo.php)中的内容
很抱歉,我努力做到最好。
预先感谢亲爱的网络空间。
最佳答案
我不知道这是否是您想要的解决方案...
有一个专门用于执行此操作的插件。 http://jquery.malsup.com/cycle2/
它遍历内容,并允许您指定导航链接,过渡效果等。
关于javascript - jQuery onclick导航上一个按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20830538/