$(document).scroll is not firing in IE8 only

后端 未结 2 971
失恋的感觉
失恋的感觉 2020-12-30 21:59

I have a site running some javascript. In IE8 only, the $(document).scroll is not firing when you scroll with or without the mousewheel. Code snippet below:



        
相关标签:
2条回答
  • 2020-12-30 22:13

    Try using window:

      $(window).scroll(function () {
        //do something on scroll
      });
    
    0 讨论(0)
  • 2020-12-30 22:18

    For a lot of areas, IE ties the event to window rather than document as other browsers will. $(window).scroll(function(e) {}); is what you're after here. Should generally also work in most other browsers too, but if not, use a check on the navigator to find IE and use window or document based on that Boolean.

    0 讨论(0)
提交回复
热议问题