所以我試圖動畫一個簡單的水平滾動使用jQuery,但它不會觸發,爲什麼?爲什麼我不能讓我的jQuery leftScroll動畫起作用?
http://jsfiddle.net/langoon/b5ZTH/
HTML
<a href="#1">1</a>
<a href="#2">2</a>
<a href="#3">3</a>
<section>
<a name="1">1</a>
<a name="2">2</a>
<a name="3">3</a>
<section>
CSS
section {
width: 100%;
overflow: auto;
white-space: nowrap;
}
a[name] {
width: 100%;
display: inline-block;
white-space: normal;
}
a[name='1'] {
background-color: green;
}
a[name='2'] {
background-color: yellow;
}
a[name='3'] {
background-color: red;
}
jQuery的
$('a[href]').click(function(){
$('section').stop().animate({
scrollLeft: $(this.hash).offset().left
}, 1000);
});
它工作正常鉻 – MCSI 2012-08-10 14:15:36
@MCSI不爲我工作,我使用Chrome瀏覽器? – unitario 2012-08-10 14:19:12