繁体   English   中英

Onclick幻灯片到当前div

[英]Onclick slide to current div

当前,主页上有各行,每行都有一个按钮。 单击该按钮时,div将向上滑动到页面顶部。 但是与此同时,按钮上还添加了另一个操作。 以下是我的js代码:

$( ".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

        });

我正在使用scrollify js $ .scrollify.move(“#name”); 但它似乎不适用于div-section-name,也可以通过其他方法来实现。

使用jQuery,一段代码-

 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);
  };

看到我的一些答案,

ANSWER1

ANSWER2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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