简体   繁体   中英

issue | JQuery slide forces my page to scroll to the top

This my slide HTML :

<div class="slide_container">
        <div class="one_slide">
            <a href="#"><img alt="slide_img" class="slide_img img-responsive" src="images/slide2.jpg"></a>
        </div>
        <div class="one_slide">
            <a href="#"><img alt="slide_img" class="slide_img img-responsive" src="images/slide3.jpg"></a>
        </div>
        <div class="one_slide">
                <a href="#"><img alt="slide_img" class="slide_img img-responsive" src="images/slide4.jpg"></a>
        </div>

</div>

And the JQuery :

setInterval(function(){
    $('.active').removeClass('active').addClass('old_active');
    if($('.old_active').is(':last-child')){
      $('.one_slide').first().addClass('active');
    }
    else{
      $('.old_active').next().addClass('active');
    }
    $('.old_active').removeClass('old_active');
    $('.one_slide').fadeOut(500);
    $('.active').fadeIn(500);
},5000);

This is my JQuery slide, the problem with it is when the image change it's forcing my page to scroll to the top and i don't like this, i searched for the same issue but no result .

尝试删除'href =“#”',这是向上滚动的原因!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM