gpt4 book ai didi

javascript - 单击按钮时将焦点设置在滚动上

转载 作者:行者123 更新时间:2023-12-02 20:38:06 25 4
gpt4 key购买 nike

window.addEvent('domready', function(){ var 总增量 = 0; 变量增量= 560; var maxRightIncrement = 增量*(-6); var fx = new Fx.Style('slider-list', 'margin-left', { 持续时间:1000, 过渡:Fx.Transitions.Back.easeInOut, 等待:真实 }); //------------------------------------------------ //“上一个”按钮的事件 $('上一个').addEvents({ '点击':函数(事件){ if(totIncrementmaxRightIncrement){ totIncrement = totIncrement-增量; fx.stop() fx.start(totIncrement); } } }) });

在 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&gt;
</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>

最佳答案

这是 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();

关于javascript - 单击按钮时将焦点设置在滚动上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2909007/

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