+ 1

javascript file not working in django Why?

when i see error in console -- >Uncaught SyntaxError: Unexpected token ';' why? $(document).ready(function() { $("ul li > a").click(function() { $("ul li > a").removeAttr("class"); $(this).addClass("home"); } ); $("ul li a").click(function() { var e=$(this.hash); $("body, html").animate( { scrollTop: e.offset().top; } , 700); return false; } ); $(window).scroll(function() { if($(this).scrollTop()>500) { $(".top").fadeIn(); } else { $(".top").fadeOut(); } }); $(".top").click(function() { $("body, html").animate( { scrollTop: 0; } , 500); return false; } ); })

27th Dec 2019, 12:22 PM
kokito
4 Respuestas
+ 2
those two scrollTop statements shouldn't be ended with ; because the animate function arguments should be an object, you can end with, or no ending punctuation. animate({ //not to end with ; here })
27th Dec 2019, 1:11 PM
Gordon
Gordon - avatar
0
@Mirielle The code from which I copied worked there But not with me
27th Dec 2019, 12:51 PM
kokito
0
@gordno scrollTop: e.offset().top this?
27th Dec 2019, 7:21 PM
kokito