Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #166312
    ming
    Participant

    Hi X,

    I’d like to use smooth scroll to jump to anchors. It works perfect using this code:

    jQuery(document).ready(function(){
      jQuery('a[href^="#"]').on('click',function (e) {
          e.preventDefault();
    
          var target = this.hash;
          $target = jQuery(target);
    
          jQuery('html, body').stop().animate({
              'scrollTop': $target.offset().top-100
          }, 900, 'swing', function () {
              window.location.hash = target;
          });
      });
    });

    unfortunately this function also takes effect on the accordions i use!

    How do I exclude accordions from that function?

    thanks!

    #166528
    Zeshan
    Member

    Hi there,

    Thanks for writing in!

    You can use following code instead:

    jQuery(document).ready(function(){
      jQuery('a[href^="#"]:not(.x-accordion-toggle)').on('click',function (e) {
          e.preventDefault();
    
          var target = this.hash;
          $target = jQuery(target);
    
          jQuery('html, body').stop().animate({
              'scrollTop': $target.offset().top-100
          }, 900, 'swing', function () {
              window.location.hash = target;
          });
      });
    });
    

    Hope this helps. 🙂

    Thank you.

  • <script> jQuery(function($){ $("#no-reply-166312 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>