Jquery 票务中心赢得';t循环一周,到达底部前停止
我曾尝试在这个网站的大多数页面的右侧栏中做一个标记:[例如] 它部分起作用。由于某种原因,股票没有到达最后一个项目的底部,并停止旋转。我希望它在一个无休止的循环中旋转 使用的jquery如下所示:Jquery 票务中心赢得';t循环一周,到达底部前停止,jquery,ticker,Jquery,Ticker,我曾尝试在这个网站的大多数页面的右侧栏中做一个标记:[例如] 它部分起作用。由于某种原因,股票没有到达最后一个项目的底部,并停止旋转。我希望它在一个无休止的循环中旋转 使用的jquery如下所示: $(function() { //cache the ticker var ticker = $("#ticker"); //wrap dt:dd pairs in divs ticker.children().filter("dt").each(function(
$(function() {
//cache the ticker
var ticker = $("#ticker");
//wrap dt:dd pairs in divs
ticker.children().filter("dt").each(function() {
var dt = $(this),
container = $("<div>");
dt.next().appendTo(container);
dt.prependTo(container);
container.appendTo(ticker);
});
//hide the scrollbar
ticker.css("overflow", "hidden");
//animator function
function animator(currentItem) {
//work out new anim duration
var distance = currentItem.height(),
duration = (distance - Math.abs(parseInt(currentItem.css("marginTop")))) / 0.025;
//animate the first child of the ticker
currentItem.animate({ marginTop: -distance }, duration, "linear", function() {
//move current item to the bottom
currentItem.appendTo(currentItem.parent()).css("marginTop", 0);
//recurse
animator(currentItem.parent().children(":first"));
});
};
//start the ticker
animator(ticker.children(":first"));
//set mouseenter
ticker.mouseenter(function() {
//stop current animation
ticker.children().stop();
});
//set mouseleave
ticker.mouseleave(function() {
//resume animation
animator(ticker.children(":first"));
});
});
$(函数(){
//缓存股票代码
var股票代码=$(“#股票代码”);
//将dt:dd对包裹在div中
ticker.children().filter(“dt”).each(function(){
var dt=$(此),
容器=$(“”);
dt.next().appendTo(容器);
dt.prependTo(容器);
集装箱。附件(股票代码);
});
//隐藏滚动条
css(“溢出”、“隐藏”);
//动画师函数
函数动画师(currentItem){
//制定新的动画持续时间
var距离=currentItem.height(),
duration=(distance-Math.abs(parseInt(currentItem.css(“marginTop”)))/0.025;
//设置股票代码的第一个子项的动画
动画({marginTop:-distance},持续时间,“线性”,函数(){
//将当前项移到底部
currentItem.appendTo(currentItem.parent()).css(“marginTop”,0);
//重现
动画师(currentItem.parent().children(“:first”);
});
};
//启动自动售票机
动画师(儿童(“:first”);
//设置鼠标器
ticker.mouseenter(函数(){
//停止当前动画
ticker.children().stop();
});
//设置鼠标删除
ticker.mouseleave(函数(){
//恢复动画
动画师(儿童(“:first”);
});
});
我还做了一个JSFIDLE:
我将感谢任何帮助或指点,我只是在学习jquery/javascript类型的东西!谢谢大家! 不经意间注释掉的代码行是导致问题的原因 不经意间注释掉的代码行是导致问题的原因 我看不出这两个问题,你使用哪种浏览器?我试过Chrome、Safari和Firefox。我根本看不到它们在旋转。。。但是看看你在jquery中放了图片的地方[对不起,我忘了放实际的图片了!]我发现你没有做任何改变,但它是有效的。。。我现在很困惑!当你在black-kite.co.uk/about.php上查看它时,例如[rhs栏,在客户端/合作伙伴框中]它对你有用吗?谢谢你的帮助-这是一行无意中被注释掉的代码。我看不出这两个问题,你使用哪种浏览器?我试过Chrome、Safari和Firefox。我根本看不到它们在旋转。。。但是看看你在jquery中放了图片的地方[对不起,我忘了放实际的图片了!]我发现你没有做任何改变,但它是有效的。。。我现在很困惑!当你在black-kite.co.uk/about.php上查看它时,例如[rhs栏,在客户/合作伙伴框中]它对你有用吗?谢谢你的帮助-这是一行无意中注释掉的代码。