Php jQuery newsTicker鼠标悬停
我已经在jQuery中制作了一个newsTicker,但需要暂停悬停。到目前为止,我所做的工作如下: php文件newsticker.php 当鼠标悬停时,如何暂停新闻并在不同的div框中显示Php jQuery newsTicker鼠标悬停,php,jquery,Php,Jquery,我已经在jQuery中制作了一个newsTicker,但需要暂停悬停。到目前为止,我所做的工作如下: php文件newsticker.php 当鼠标悬停时,如何暂停新闻并在不同的div框中显示 运行JSFIDLE link首先,里面有一个小bug。然后我们使用小技巧 var ticker = function() { setTimeout(function(){ $('#ticker li:first:not(.stop)').animate( {marginTop: '
运行JSFIDLE link首先,里面有一个小bug。然后我们使用小技巧
var ticker = function()
{
setTimeout(function(){
$('#ticker li:first:not(.stop)').animate( {marginTop: '-120px'}, 800, function()
{
var me = $(this);
me
.clone(true)
.appendTo('ul#ticker')
.removeAttr('style')
me.remove();
});
ticker();
}, 4000);
};
ticker();
// simply toggle class on hover
// animation will not run with `li` having this class
$('#ticker li').hover(function() {
$(this).addClass('stop')
}, function() {
$(this).removeClass('stop')
});
请添加一个plunkr或jsfiddle。Thanks@Robin我的jsfiddle链接几乎尝试了所有if和but,但并没有真正实现
$(document).ready(function() {
var ticker = function() {
setTimeout(function(){
$('#ticker li:first').animate({
marginTop: '-120px'},
800,
function() {
$(this).detach().appendTo('ul#ticker').removeAttr('style');
});
ticker();
}, 4000);
};
ticker();
});
var ticker = function()
{
setTimeout(function(){
$('#ticker li:first:not(.stop)').animate( {marginTop: '-120px'}, 800, function()
{
var me = $(this);
me
.clone(true)
.appendTo('ul#ticker')
.removeAttr('style')
me.remove();
});
ticker();
}, 4000);
};
ticker();
// simply toggle class on hover
// animation will not run with `li` having this class
$('#ticker li').hover(function() {
$(this).addClass('stop')
}, function() {
$(this).removeClass('stop')
});