jQuery技术:我发现了一个jquery图像旋转脚本,并添加了图像的超链接打破了动画

发现这篇关于使用jquery进行图像交换的好文章:

https://jquery-howto.blogspot.com/2009/05/replacing-images-at-time-intervals.html

你怎么建议我超链接图像?

    了解jquery如何工作并修复它! 或者使用诸如循环插件之类的插件 – 这仍然需要一些jquery知识。

    未经测试但它应该工作……

    function swapImages(tag){ var element = tag||'img'; var $active = $('#myGallery '+tag+'.active'); var $next = ($('#myGallery '+tag+'.active').next().length > 0) ? $('#myGallery '+tag+'.active').next() : $('#myGallery '+tag+':first'); $active.fadeOut(function(){ $active.removeClass('active'); $next.fadeIn().addClass('active'); }); } setInterval(function(){swapImages('a');}, 5000); // or the original usage with no links on the images setInterval(swapImages, 5000); 

    请记住你提供的任何内容,因为tag会让课程active因此将css称为nessecary。

    无论如何,这非常简单 – 我还建议做一些教程或阅读jQuery的文档。 您应该能够在阅读时解析此脚本 – 非常简单:-)

    解决了它:

     function swapImages() { var $active = $('#myGallery a:has(img) > img.active'); var $next = ($('#myGallery a:has(img.active)').next().find('img').length > 0) ? $('#myGallery a:has(img.active)').next().find('img') : $('#myGallery a:has(img):first > img'); $active.fadeOut(function() { $active.removeClass('active'); $next.fadeIn().addClass('active'); }); } 

      以上就是jQuery教程分享我发现了一个jquery图像旋转脚本,并添加了图像的超链接打破了动画相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

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

      ctvol管理联系方式QQ:251552304

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

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

      精彩推荐