Why is not working .click and add a class?

$(window).scroll(function() {
 if ($(this).scrollTop() > $(this).height()) {
$('.top').addClass('active');
 } else {
$('.top').removeClass('active');
}
});
$('.top').click(function(){
 $('html, body').stop().animate({scrollTop: 0}, 'slow', 'swing');
 });


In General, try to do the button Up, not working js script does, using gulp I tested it on LAN and on the host, to no avail, scripts prescribed in the file "common.js"

In the end, js refuses to work, error in console is not present, what to do ?

if instead
$('html, body').stop().animate({scrollTop: 0}, 'slow', 'swing');
insert
alert('pressed');
the alert is triggered

$('.top').click(function(){
 $('html, body').stop().animate({scrollTop: 0}, 'slow', 'swing');
 });
June 14th 19 at 20:34

Find more questions by tags JavaScriptjQuery