title: Listening to all scroll events on a page
body: <p><strong>Background:</strong></p>
  
  <p>I'm writing a component that opens up a sub-menu on click. I can't know where this component will be placed on the page or how far it will be nested in areas that may have the <code>overflow</code> property set.</p>
  
  <p>Given that the overflow may clip the sub-menu I am instead making the sub-menu itself be attached to the <code>body</code> giving it an absolute position and linking it via code to the original component. This takes care of the overflow issue.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>However if a user scrolls the sub-menu remains in place, rather than moving with its linked component, <strong>so I need to be able to listen to any and all scroll events that occur on the page</strong> so I can reposition the sub-menu appropriately.</p>
  
  <p>If there's an easy way to listen to all scroll events or if there's another better way to do this component I would appreciate any input.</p>
  
  <p>I've played around with JSFiddle and set up a <a href="http://jsfiddle.net/wAadt/" rel="noreferrer">sandbox</a> but I haven't had any success nor have I found an answer on this site or anywhere else for that matter; though perhaps I was using the wrong search terms, I can't imagine that I'm the first to have this question.</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p>To address the close vote, I'm not asking help to debug an issue without providing code nor am I asking something that won't help anyone in the future. I'm asking how I would go about listening to all event of a certain type not matter where the may occur, which I find globally applicable, though perhaps that's subjective.</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p><code>$(window).on('scroll', function(){ /**/ });</code>
  is not an option as it only listens to the window scroll, not any nested scrolls.</p>
  
  <p><code>$('#ex1 #ex2').on('scroll', function(){ /**/ });</code> is not an option as it requires the person who is implementing the code to  be aware of any current or possible future areas on the page that may scroll.</p>