gpt4 book ai didi

javascript - 使用 jquery 向左滚动动画

转载 作者:行者123 更新时间:2023-11-28 07:01:47 24 4
gpt4 key购买 nike

这是我当前的代码,用于单击按钮并使其滚动并更改一些内容。

$(".scroll").click(function(event) {
$('.panel h1').stop().fadeOut(200);
$('.panel p').stop().fadeOut(200);

$(".scroll").css({"background": "none", "color": "#B1B1B1"});

$(this).css({"background": "#00709C", "color": "#fff"});

event.preventDefault();

$('.scroll-menu').stop().animate({
scrollLeft: $('.scroll-menu').scrollLeft() + $(this.hash).offset().left
}, 1200);
$('.panel h1').delay( 900 ).fadeIn(500);
$('.panel p').delay( 900 ).fadeIn(500);
});

我得到了一些帮助,所以实际上我对 $(this.hash).offset().left 指的是什么感到困惑。

另外,谁能给我一个关于如何在不点击的情况下自动设置动画的想法?例如,这不起作用。

setInterval(function() {
$('.scroll-menu').stop().animate({
scrollLeft: $('.scroll-menu').scrollLeft() + $(this.hash).offset().left
}, 1200);
$('.panel h1').delay( 900 ).fadeIn(500);
$('.panel p').delay( 900 ).fadeIn(500);
}, 3600);

最佳答案

当然,给你:http://jsfiddle.net/neuroflux/afzVe/617/

以及相关代码:

$('#scroll').click(function() {
$('html,body').animate({
scrollLeft: $('#test').css('left')
}, 800, function() {

$('html, body').animate({
scrollLeft: 0
}, 800);

});
});

关于javascript - 使用 jquery 向左滚动动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32073134/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com