TypeError jQuery offset().top is undefined

后端 未结 1 819
自闭症患者
自闭症患者 2020-12-07 00:33

The Firefox debugger is showing a TypeError for a jQuery function aimed at sticking a navbar to the to the top of the page when a user scrolls and updating the class at the

相关标签:
1条回答
  • 2020-12-07 00:57

    It 's because your $(".navbar") cannot be found. Check if the element exist before getting offset.

    if ($(".navbar").length) {...}
    
    0 讨论(0)
提交回复
热议问题