Javascript 我想做一个新闻播报员。但是有';鼠标悬停后离开时出错

Javascript 我想做一个新闻播报员。但是有';鼠标悬停后离开时出错,javascript,jquery,ticker,Javascript,Jquery,Ticker,鼠标离开后,股票行情开始以非常高的速度移动。不知道是什么错误 Javascript: $('#tick2').html($('#tick').html()); var temp=0,intervalId=0; $('#tick li').each(function() { var offset=$(this).offset(); var offsetLeft=offset.left; $(this).css({'left':offsetLeft+temp}); t

鼠标离开后,股票行情开始以非常高的速度移动。不知道是什么错误

Javascript:

$('#tick2').html($('#tick').html());
var temp=0,intervalId=0;
$('#tick li').each(function() {
    var offset=$(this).offset();
    var offsetLeft=offset.left;
    $(this).css({'left':offsetLeft+temp});
    temp=$(this).width()+temp+10;
});
$('#tick').css({'width':temp+40, 'margin-left':'20px'});
temp=0;
$('#tick2 li').each(function(){
    var offset=$(this).offset();
    var offsetLeft=offset.left;
    $(this).css({'left':offsetLeft+temp});
    temp=$(this).width()+temp+10;
});
$('#tick2').css({'width':temp+40,'margin-left':temp+40});

function abc(a,b) {  
    $('#outer').mouseenter(function() { window.clearInterval(intervalId);intervalId=0; });
    $('#outer').mouseleave(function() { start(); })
    var marginLefta=(parseInt($("#"+a).css('marginLeft')));
    var marginLeftb=(parseInt($("#"+b).css('marginLeft')));
    if((-marginLefta<=$("#"+a).width())&&(-marginLefta<=$("#"+a).width())){
        $("#"+a).css({'margin-left':(marginLefta-1)+'px'});
    } else {
        $("#"+a).css({'margin-left':temp});
    }
    if((-marginLeftb<=$("#"+b).width())){
        $("#"+b).css({'margin-left':(marginLeftb-1)+'px'});
    } else {
        $("#"+b).css({'margin-left':temp});
    }
} 

function start() { intervalId = window.setInterval(function() { abc('tick','tick2'); }, 10) }

start();
$('tick2').html($('tick').html());
变量温度=0,有效期=0;
$('#勾选li')。每个(函数(){
var offset=$(this.offset();
var offsetLeft=offset.left;
$(this.css({'left':offsetLeft+temp});
temp=$(this).width()+temp+10;
});
$('tick').css({'width':temp+40,'marginleft':'20px');
温度=0;
$('2 li')。每个(函数(){
var offset=$(this.offset();
var offsetLeft=offset.left;
$(this.css({'left':offsetLeft+temp});
temp=$(this).width()+temp+10;
});
$('tick2').css({'width':temp+40,'margin-left':temp+40});
函数abc(a,b){
$('#outer').mouseenter(函数(){window.clearInterval(intervalId);intervalId=0;});
$('#outer').mouseleave(函数(){start();})
var marginLefta=(parseInt($(“#“+a).css('marginLeft'));
var marginLeftb=(parseInt($(“#“+b).css('marginLeft'));

如果(-marginLefta嗯,你差点炸毁了我的浏览器!你能试试这个吗:

 function abc(a,b) {  

var marginLefta=(parseInt($("#"+a).css('marginLeft')));
var marginLeftb=(parseInt($("#"+b).css('marginLeft')));
if((-marginLefta<=$("#"+a).width())&&(-marginLefta<=$("#"+a).width())){
    $("#"+a).css({'margin-left':(marginLefta-1)+'px'});
} else {
    $("#"+a).css({'margin-left':temp});
}
if((-marginLeftb<=$("#"+b).width())){
    $("#"+b).css({'margin-left':(marginLeftb-1)+'px'});
} else {
    $("#"+b).css({'margin-left':temp});
}
} 

 function start() { intervalId = window.setInterval(function() { abc('tick','tick2'); }, 10) }

 $(function(){
      $('#outer').mouseenter(function() { window.clearInterval(intervalId); });
      $('#outer').mouseleave(function() { start(); })
      start();
 });
函数abc(a,b){ var marginLefta=(parseInt($(“#“+a).css('marginLeft')); var marginLeftb=(parseInt($(“#“+b).css('marginLeft'));
如果((-marginLeftaThis)太好了。非常感谢。你能建议一些补充或任何改进。或者在我的网站上使用这个好吗?