Bootstrap tabs scroll effect to content when clicked

后端 未结 2 1360
温柔的废话
温柔的废话 2020-12-21 09:48

I am using Bootstrap 3 Tabs like this:

相关标签:
2条回答
  • 2020-12-21 10:07

    I have updated your fiddle, Now its working fine

    Working Demo

    jQuery

    jQuery(document).ready(function ($) {
    
      $('.nav a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
      })  
    
      $('a.scroll').on('click', function (e) {
        var href = $(this).attr('href');
        $('html, body').animate({
          scrollTop: $(href).offset().top
          }, 'slow');
        e.preventDefault();
      });
    
    });
    
    0 讨论(0)
  • 2020-12-21 10:11

    I'm using this:

    // scroll to top action
    $('.nav-tabs li a').on('click', function(event) {
        event.preventDefault();
        $('html, body').animate({scrollTop:0}, 'fast'); 
        $(this).tab('show');    
    });
    
    0 讨论(0)
提交回复
热议问题