Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jQuery newsTicker鼠标悬停_Php_Jquery - Fatal编程技术网

Php jQuery newsTicker鼠标悬停

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: '

我已经在jQuery中制作了一个newsTicker,但需要暂停悬停。到目前为止,我所做的工作如下:

php文件newsticker.php

当鼠标悬停时,如何暂停新闻并在不同的div框中显示


运行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')
});