Hello! Tell me why the code does not work.

$(window).scroll(function(){ if($(window).scrollTop() > 100;){ $(".menu_top").css("background-color","black") }; }); 

The bottom line is this, when scrolling down the page 100px, the color of the block should change to black, but this does not happen.

Closed due to the fact that off-topic participants Air , andreymal , user194374, Edward , Kirill Korushkin 6 Jan '18 at 0:27 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Air, andreymal, Community Spirit, Edward, Kirill Korushkin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    remove the semicolon in the condition if ($ (window) .scrollTop ()> 100;) - Kirill Korushkin
  • For sure! Thank! - Andy Krish

1 answer 1

Remove the condition ;

 $(window).scroll(function(){ if($(window).scrollTop() > 100){ $(".menu_top").css("background-color","black") }; });