在mootools v1.1
中它在我的html页面底部创建了一个滚动函数。 但是当我点击下一个按钮时,页面的焦点移动到页面顶部。我怎么把它放在卷轴上?
这是html片段:
<h3>Our Pastas</h3>
<div id="slider-buttons">
<a href="#" id="previous">Previous</a> | <a href="#" id="next">Next</a>
</div>
<div id="slider-stage">
<ul id="slider-list">
<li class="list_item">
<div id="thumbnail"><a href="xxx/product-catalog/pasta/long-pasta-in-brown-bags/bucatini"><img src="xxx/images/stories/products/_thumb1/bucatini.gif"></a></div><h4><a href="xxx/product-catalog/pasta/long-pasta-in-brown-bags/bucatini">Rustichella d'Abruzzo Bucatini</a></h4>
</li>
<li class="list_item">
<div id="thumbnail"><a href="xxx/product-catalog/pasta/pasta-in-trays/calamarata"><img src="xxx/images/stories/products/_thumb1/calamarata.jpg"></a></div><h4><a href="xxx/product-catalog/pasta/pasta-in-trays/calamarata">Rustichella d'Abruzzo Calamarata</a></h4>
</li>
<li class="list_item">
<div id="thumbnail"><a href="xxx/product-catalog/pasta/pasta-in-trays/cannolicchi"><img src="xxx/images/stories/products/_thumb1/cannolicchi.jpg"></a></div><h4><a href="xxx/product-catalog/pasta/pasta-in-trays/cannolicchi">Rustichella d'Abruzzo Cannolicchi</a></h4>
</li>
</ul></div>
答案 0 :(得分:2)
这是mootools 1.11,修改你的下一个和上一个函数如下:
$('next').addEvents({
'click' : function(event){
// add this to stop the default click event.
new Event(event).stop();
// continue as usual.
if(totIncrement>maxRightIncrement){
totIncrement = totIncrement-increment;
fx.stop()
fx.start(totIncrement);
}
}
});
在mootools 1.2+中,您只需event.stop();
或event.preventDefault();