开发者

jQuery: How to make news ticker stop move when over on it

Does anyone help me to make the news items stop moving when hover on it?

http://geschke.name/dev/newsticke开发者_JAVA技巧r/

Many thanks.


I believe you would do it like this:

$('ul#listticker').hover(pauseTicker, resumeTicker);

function pauseTicker() {
    clearInterval(interval);
}

function resumeTicker() {
    interval = setInterval(newsticker, pause);
}


You can do this by adding this to the same $(document).ready(function(){ });, or move function newsticker() outside the document.ready function, which would be a bit better.

$("#listticker").hover(function() {
  clearInterval(interval);
}, function() {
  interval = setInterval(newsticker, pause);
});

This cancels the interval when hovering, and resumes it when the mouse leaves.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜