简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

jQuery制作简洁的图片轮播效果

来源:易贤网   阅读:825 次  日期:2015-04-08 14:02:03

温馨提示:易贤网小编为您整理了“jQuery制作简洁的图片轮播效果”,方便广大网友查阅!

演示图:

名单1

名单2

jQuery制作简洁的图片轮播效果 三联

核心代码:

$(document).ready(function(){

var $iBox = $('.imgBox'),

$iNum = $('.imgNum'), //缓存优化

indexImg = 1, //初始下标

totalImg = 4, //图片总数量

imgSize = 300, //图片尺寸 宽度

moveTime = 1100, //切换动画时间

setTime = 2500, //中间暂停时间

clc = null;

function moveImg(){

if(indexImg != totalImg){

$iBox.animate({

left: -(indexImg*imgSize) + 'px'

}, moveTime);

$iNum.removeClass('mark-color')

.eq(indexImg)

.addClass('mark-color');

indexImg++;

}

else{

indexImg = 1;

$iNum.removeClass('mark-color')

.eq(indexImg - 1)

.addClass('mark-color');

$iBox.animate({

left: 0

}, moveTime);

}

}

$iNum.hover(function(){

$iBox.stop(); //结束当前动画

clearInterval(clc); //暂停循环

$iNum.removeClass('mark-color');

$(this).addClass('mark-color');

indexImg = $(this).index();

$iBox.animate({

left: -(indexImg*imgSize) + 'px'

}, 500);

},function(){

clc = setInterval(moveImg, setTime);

});

clc = setInterval(moveImg, setTime);

});

更多信息请查看IT技术专栏

更多信息请查看脚本栏目
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:JavaScript使用indexOf获得子字符串在字符串中位置的方法
下一篇:javascript 实现map集合
易贤网手机网站地址:jQuery制作简洁的图片轮播效果
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!