B
B
bbaggins2017-01-14 02:05:12
JavaScript
bbaggins, 2017-01-14 02:05:12

How to make jquery move up when slick-dots is clicked?

Friends, hello everyone!
I'm confused, please help me figure it out.
With the help of slick I build a slider, the dots sign is set for the slider. Buttons appear, it is necessary that by clicking on any of the buttons, jquery scrolls the page up. What I do: I

add the required class and the second feature to slick-dots when loading:

jQuery(".slick-dots").addClass("page-scroll").attr('data-scrollid', 'up');


I twist like this:
jQuery(".page-scroll").click(function() {
  pagcenter();
    jQuery('html, body').animate({
      scrollTop: jQuery( '#' + jQuery(this).data("scrollid") ).offset().top - 120
    }, 1000, 'swing');
  });


The dots itself is built during the page load, see the screenshot below:
3d87f425ca8646f08847651d598187b0.png

Everything works fine except for scrolling, why doesn't it want to scroll... If I add class="page-scroll" data-scrollid="up" to a static element, there are no problems, it spins with a bang.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
justdealman, 2017-01-14
@justdealman

jQuery('html').delegate('.page-scroll', 'click', function() {
  pagcenter();
  jQuery('html, body').animate({
    scrollTop: jQuery( '#' + jQuery(this).data('scrollid') ).offset().top - 120
  }, 1000, 'swing');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question