Commit ce9f4b54 by lmf

优化首页轮播图js

parent e9bde23d
...@@ -59,40 +59,4 @@ ...@@ -59,40 +59,4 @@
<li class="current">1</li> <li class="current">1</li>
<li>2</li> <li>2</li>
</ul> </ul>
</div> </div>
\ No newline at end of file
<script>
require(['jquery'], function ($) {
$(function () {
console.log('111');
// 记录当前显示的图片的索引
var current=0;
// 保存定时器
var timer=null;
timer=setInterval(autoPlay,3000)
// 自动播放
function autoPlay(){
current<$('.count li').length-1?current++:current=0;
show()
}
function show(){
$('.list li').hide()
.eq(current).show();
$('.count li').eq(current).toggleClass('current').siblings().removeClass('current');
}
// 手动
$('.count li').mouseenter(function(){
current=$(this).index()
show()
})
// 鼠标进图自动暂停
$('#box').hover(function(){
clearInterval(timer);
},function(){
timer = setInterval(autoPlay,3000);
})
});
})
</script>
\ No newline at end of file
...@@ -15,4 +15,32 @@ ...@@ -15,4 +15,32 @@
$(this).children("span").html('>') $(this).children("span").html('>')
} }
}) })
//home
// 记录当前显示的图片的索引
var current=0;
// 保存定时器
var timer=null;
timer=setInterval(autoPlay,3000)
// 自动播放
function autoPlay(){
current<$('.count li').length-1?current++:current=0;
show()
}
function show(){
$('.list li').hide()
.eq(current).show();
$('.count li').eq(current).toggleClass('current').siblings().removeClass('current');
}
// 手动
$('.count li').mouseenter(function(){
current=$(this).index()
show()
})
// 鼠标进图自动暂停
$('#box').hover(function(){
clearInterval(timer);
},function(){
timer = setInterval(autoPlay,3000);
})
})(); })();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment