手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮
jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮
摘要:jquery左右滚动焦点图banner图片,鼠标经过显示上下页适合宽和高都比较大的页面使用演示复制代码代码如下:复制代码代码如下:@char...

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

适合宽和高都比较大的页面使用

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

演示

复制代码 代码如下:

<div>

<div id="focus">

<ul>

<li><a href="http://www.freejs.net/" target="_blank">

<img src="../dandong.png" /></a></li>

<li><a href="http://www.freejs.net/" target="_blank">

<img src="../mohe.png" /></a></li>

<li><a href="http://www.freejs.net/" target="_blank">

<img src="../changbaishan.png" /></a></li>

<li><a href="http://www.freejs.net/" target="_blank">

<img src="../erlianhaote.png" /></a></li>

</ul>

</div>

</div>

复制代码 代码如下:

@charset "utf-8";

img { border: 0px; }

.bannerbox { width: 320px; height: 150px; overflow: hidden; margin: 0px auto; }

#focus { width: 320px; height: 150px; clear: both; overflow: hidden; position: relative; float: left; }

#focus ul { width: 320px; height: 150px; float: left; position: absolute; clear: both; padding: 0px; margin: 0px; }

#focus ul li { float: left; width: 320px; height: 150px; overflow: hidden; position: relative; padding: 0px; margin: 0px; }

#focus .preNext { width: 250px; height: 150px; position: absolute; top: 0px; cursor: pointer; }

#focus .pre { left: 0; background: url(../images/sprite.png) no-repeat left center; }

#focus .next { rightright: 0; background: url(../images/sprite1.png) no-repeat rightright center; }

js文件

复制代码 代码如下:

$(function () {

var sWidth = $("#focus").width();

var len = $("#focus ul li").length;

var index = 0;

var picTimer;

var btn = "<div></div><div>";

for (var i = 0; i < len; i++) {

btn += "<span></span>";

}

btn += "</div><div></div><div></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);

}

});

【jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮】相关文章:

判断是否输入完毕再激活提交按钮

js实现鼠标经过表格行变色的方法

jQuery实现表格行上移下移和置顶的方法

JavaScript中this关键字使用方法详解

jQuery的基本概念与高级编程

深入浅出理解javaScript原型链

JQuery boxy插件在IE中边角图片不显示问题的解决

jquery预加载图片的方法

jQuery实现鼠标经过图片变亮其他变暗效果

jQuery插件expander实现图片翻转特效

精品推荐
分类导航