0

I have a class that I add to navbar with jQuery. It works perfectly fine on android phones, tablets, desktop but not on iphones. I have no clue on what might be the issue. Actually the class is added except the part background-color?

Here is the code:

$(window).scroll(function(){
        var vlera = $(this).scrollTop();
        if(vlera > 0){
            $('.navbar').addClass('n-bg');
        }
        else
        {
            $('.navbar').removeClass('n-bg');
        }
     })
David Thomas
  • 249,100
  • 51
  • 377
  • 410
  • Step up to what? – Poul Bak Nov 18 '18 at 10:19
  • 1
    "*Also [I] want to note that this is the very last time [I] use [jQuery]. Time to step up.*" - this is entirely irrelevant to your question (which is why I removed it). If you log `viera` to the screen in iPhones does it report a value that you expect? – David Thomas Nov 18 '18 at 10:20
  • @DavidThomas well i admit you are right –  Nov 18 '18 at 10:23
  • @DavidThomas i editet the question a bit. The class is added but not the background color? –  Nov 18 '18 at 10:25
  • 1
    Can you post enough of your code that those of us with iPhones can view what happens? Please: read the [mcve] guidelines for what we'd need to see. – David Thomas Nov 18 '18 at 10:28
  • 1
    It seems like iOS have some issues with `jQuery`'s `scrollTop()` function. [Check this question](https://stackoverflow.com/questions/30478157/jquery-scrolltop-not-working-inside-iframe-on-ios) – trinaldi Nov 18 '18 at 10:48

0 Answers0