源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮

  • 时间:2022-06-22 18:53 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮
jquery左右滚动焦点图banner图片,鼠标经过显示上下页 适合宽和高都比较大的页面使用 [img]http://files.jb51.net/file_images/article/201310/20131011151559.jpg?2013911151646[/img]   [url=http://www.freejs.net/demo/53/index.html]演示[/url]
[url=http://www.freejs.net/]<img src="../dandong.png" alt="" /></a></li> <li><a href="http://www.freejs.net/" target="_blank"> <img src="../mohe.png" alt="" /></a></li> <li><a href="http://www.freejs.net/" target="_blank"> <img src="../changbaishan.png" alt="" /></a></li> <li><a href="http://www.freejs.net/" target="_blank"> <img src="../erlianhaote.png" alt="" /></a></li> </ul> </div> </div>
js文件
[u]复制代码[/u] 代码如下:
$(function () { var sWidth = $("#focus").width(); var len = $("#focus ul li").length; var index = 0; var picTimer; var btn = "<div class='btnBg'></div><div class='btn'>"; for (var i = 0; i < len; i++) { btn += "<span></span>"; } btn += "</div><div class='preNext pre'></div><div class='preNext next'></div>"; $("#focus").append(btn); $("#focus .btnBg").css("opacity", 0); $("#focus .btn span").css("opacity", 0.4).mouseenter(function () { index = $("#focus .btn span").index(this); showPics(index); }).eq(0).trigger("mouseenter"); $("#focus .preNext").css("opacity", 0.0).hover(function () { $(this).stop(true, false).animate({ "opacity": "0.5" }, 300); }, function () { $(this).stop(true, false).animate({ "opacity": "0" }, 300); }); $("#focus .pre").click(function () { index -= 1; if (index == -1) { index = len - 1; } showPics(index); }); $("#focus .next").click(function () { index += 1; if (index == len) { index = 0; } showPics(index); }); $("#focus ul").css("width", sWidth * (len)); $("#focus").hover(function () { clearInterval(picTimer); }, function () { picTimer = setInterval(function () { showPics(index); index++; if (index == len) { index = 0; } }, 2800); }).trigger("mouseleave"); function showPics(index) { var nowLeft = -index * sWidth; $("#focus ul").stop(true, false).animate({ "left": nowLeft }, 300); $("#focus .btn span").stop(true, false).animate({ "opacity": "0.4" }, 300).eq(index).stop(true, false).animate({ "opacity": "1" }, 300); } });
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部