Nick Mwaniki
Nick Mwaniki

Reputation: 23

Jquery code not working for scrolling animation on page

This is my Query code:

$(document).ready(function () {

       $('.js--scroll-to-discount').click(function () {
             $('html, body').animate({scrollTop: $('js--section-discount-opt').offset().top}, 1000);
       });

});

This is the HTML code of the button to be clicked:

<a class="btn btn-full js--scroll-to-discount" href="#">I'm ready Dallas</a>

This is the section the animation should take you within the page:

<section class="discount-city js--section-discount-opt">

Upvotes: 1

Views: 35

Answers (1)

Chris Hawkes
Chris Hawkes

Reputation: 12430

you have an error in your code

$(document).ready(function () {

       $('.js--scroll-to-discount').click(function () {
             $('html, body').animate({scrollTop: $('js--section-discount-opt').offset().top}, 1000);
       });

});

should be

$(document).ready(function () {

       $('.js--scroll-to-discount').click(function () {
             $('html, body').animate({scrollTop: $('.js--section-discount-opt').offset().top}, 1000);
       });

});

Upvotes: 1

Related Questions