我写这段代码,它为我做了一个幻灯片 现在我需要当鼠标停止滑动时 方面
$(document).ready(function () {
$('#ticker_02').mouseover(function() {
//I NEED THIS CODE
})
});
function tick2(){
$('#ticker_02 li:first').slideUp( function () { $(this).appendTo($('#ticker_02')).slideDown(); });
}
setInterval(function(){ tick2 () }, 2000);
答案 0 :(得分:1)
尝试stop()
方法:
$('#ticker_02').mouseover(function() {
$(this).stop(true);
})
答案 1 :(得分:0)
function tick2(){
$('#ticker_02 li:first').slideUp(
function () {
$(this).appendTo($('#ticker_02')).slideDown();
}
);
}
d=setInterval(function(){ tick2 () }, 5000);
function stop1(){
clearInterval(d);
}
function start1(){
d=setInterval(function(){ tick2 () }, 5000);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="ticker_02" class="ticker" onmouseover="stop1()" onmouseout="start1()" >
<li>element1</li>
<li>element2</li>
</ul>
答案 2 :(得分:0)
试试这个。
<ul id="ticker_02" class="ticker" onmouseover="stop1()" onmouseout="start1()">
<script>
var d
function tick2(){
$('#ticker_02 li:first').slideUp( function () {
$(this).appendTo($('#ticker_02')).slideDown(); });
}
d=setInterval(function(){ tick2 () }, 2000);
function stop1(){
clearInterval(d);
}
function start1(){
setInterval(function(){ tick2 () }, 2000);
}
</script>