jQuery技术:jquery图像分页

我有jsp文件中的图像列表,我希望一次显示5个分页。 如何使用jquery做到这一点?

提前致谢

    我做了一个快速演示, jsFiddle 。

    prev和next链接是可选的。 如果需要,只需更改“var start = 0”即可。

    HTML

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    jQuery的

     var start = 0; var nb = 5; var end = start + nb; var length = $('.img-list img').length; var list = $('.img-list img'); list.hide().filter(':lt('+(end)+')').show(); $('.prev, .next').click(function(e){ e.preventDefault(); if( $(this).hasClass('prev') ){ start -= nb; } else { start += nb; } if( start < 0 || start >= length ) start = 0; end = start + nb; if( start == 0 ) list.hide().filter(':lt('+(end)+')').show(); else list.hide().filter(':lt('+(end)+'):gt('+(start-1)+')').show(); }); 

    可能是你想说的图像滑块。 检查我用Google搜索的链接。

    您可以修改JSP以接受两个参数(例如startImg,howMany),并根据这些参数输出一些HTML以注入页面:

     $("a.pageNumber").click(function() { $.get('images.jsp', {startImg: $(this).text(), howMany: 5}, function(response) { $("#imageDiv").html(response); // response contains some  tags }); return false; }); 

      以上就是jQuery教程分享jquery图像分页相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/jquerytutorial/558851.html

      (0)
      上一篇 2021年2月1日
      下一篇 2021年2月1日

      精彩推荐