0

Currently, I have various rows on the homepage, and each row has a button. When the button is clicked, the div will slide up to the top of the page. But meanwhile, there is another action added to the button as well. Below is my js code:

$( ".expandable-container-mobile").click(function() {

            var el = $(this).find('.mobile-show-section');//get the current element
            var el2 = $(this).find('.expandable');

            el.stop().slideToggle(700);//toggle the current one 
            $(this).children('.expandable').toggleClass('clicked');  


            $('.expandable').not(el2).removeClass('clicked');
            $('.mobile-show-section').not(el).stop().slideUp();//hide the rest

        });

I am using scrollify js $.scrollify.move("#name"); but it doesn't seem to work with the div-section-name, other way to achieve it is fine as well.

David Guan
  • 4,180
  • 1
  • 25
  • 32
zacwhyyy
  • 13
  • 4

1 Answers1

0

Use jQuery, piece of code-

 function scrollToAnchor(aid){
     //get the element to be scrolled
     var el = $(this).find('.mobile-show-section');
     //then scroll it using jQuery annimation
     $('html,body').animate({scrollTop: el.offset().top},500);
  };

See some of my answers,

Answer1

Answer2

Sudhansu Choudhary
  • 3,322
  • 3
  • 19
  • 30