阻止页面在jQuery函数之后重新加载或向上移动

Prevent page to reload or move up after jQuery function

本文关键字:加载 移动 新加载 jQuery 之后 函数      更新时间:2023-09-26

我使用toggleslideDown函数来显示/隐藏buttonsDivs。一切都很好——除了这样一个事实——每当我点击一个按钮,页面就会重新加载,而slideDown的效果离底部太近,用户看不到它。我该如何防止这种情况?

jQuery

$(document).ready(function(){
     $("#banner_step_2").hide();
$("#next_btn_info_id").click(function(){
    $("#banner_step_2").slideDown(500);
  });
    });

HTML

<div class="next_btn_info" id="next_btn_info_id">
   <a href="#"><?php echo $lang ['next']; ?></a>
</div>  
<div class="clearfix"></div>
<article class="order_form_banner_step_2" id="banner_step_2">
</article>

很抱歉提供了错误的信息,我刚刚注意到,当slideDown功能处于活动状态时,页面没有重新加载,只是向上滑动。所以我的问题仍然是一切都发生在屏幕的底部和外部。我怎么能有一个slideDown函数,但同时scrolling和它一起一直到Div的顶部?

e.preventDefault();return false;是您作为解决方案所需要的。