[Solved] Where syntax error?


Header isn’t a variable that you’ve defined. You need to place quotations before and after header to refer to the DOM element. When you don’t include those quotations jQuery expects a reference to a defined variable.

Here is what I would try:

   $(document).ready(function() {   
    $(window).scroll(function () {
        if ($(this).scrollTop() > 30) {
            $('.logo').addClass("two");
            $('.logo').removeClass("one");
        } else {
            $('.logo').removeClass("two");
        }
       });
    });

Or, you can define .logo as a jQuery object:

var logo = $('.logo');
$(window).scroll(function () {
        if ($(this).scrollTop() > 30) {
            $(logo).addClass("two");
            $(logo).removeClass("one");
        } else {
            $(logo).removeClass("two");
        }
       });
    });

3

solved Where syntax error?