Javascript 使用jquery设置向左滚动的动画
下面是我当前的代码,用于单击按钮,滚动浏览并更改一些内容Javascript 使用jquery设置向左滚动的动画,javascript,jquery,css,Javascript,Jquery,Css,下面是我当前的代码,用于单击按钮,滚动浏览并更改一些内容 $(".scroll").click(function(event) { $('.panel h1').stop().fadeOut(200); $('.panel p').stop().fadeOut(200); $(".scroll").css({"background": "none", "color": "#B1B1B1"}); $(this).css({"background": "#0070
$(".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);
当然,给你:
及有关守则:
$('#scroll').click(function() {
$('html,body').animate({
scrollLeft: $('#test').css('left')
}, 800, function() {
$('html, body').animate({
scrollLeft: 0
}, 800);
});
});
当然,给你:
及有关守则:
$('#scroll').click(function() {
$('html,body').animate({
scrollLeft: $('#test').css('left')
}, 800, function() {
$('html, body').animate({
scrollLeft: 0
}, 800);
});
});
假设您有一个
anchor
标记,如下所示:
<a href="#foo" class="scroll">Some anchor</a>
var elem=$(".scroll");//store it globally
setInterval(function() {
$('.scroll-menu').stop().animate({
scrollLeft: $('.scroll-menu').scrollLeft() + $(elem.hash).offset().left
}, 1200);
$('.panel h1').delay( 900 ).fadeIn(500);
$('.panel p').delay( 900 ).fadeIn(500);
}, 3600);
假设您有一个
anchor
标记,如下所示:
<a href="#foo" class="scroll">Some anchor</a>
var elem=$(".scroll");//store it globally
setInterval(function() {
$('.scroll-menu').stop().animate({
scrollLeft: $('.scroll-menu').scrollLeft() + $(elem.hash).offset().left
}, 1200);
$('.panel h1').delay( 900 ).fadeIn(500);
$('.panel p').delay( 900 ).fadeIn(500);
}, 3600);