title: How to check if an event is bound to an element, to prevent duplicate bindings?
body: <p>I have a function that basically creates an overlay div element that covers the entire page. It also binds a resize event to window so whenever the window is resized the overlay also changes its size:</p>
  
  <pre><code>function stdOverlay() {
      var overlay = $('&lt;div /&gt;').css({width : $(window).width(), height : $(window).height()});
      var overlayResize =
      function() {
          $(overlay).css({width : $(window).width(), height : $(window).height()});
      };
      $('body').append(overlay);
      $(window).resize(overlayResize);
      //... other codes,  like remove overlay and unbind the events
      //$('div.stdgui-overlay').unbind('resize', overlayResize);
  }
  </code></pre>
  
  <p>each time the function is called it add's an overlay, if there isn't any, and binds a resize event to the window. It also unbinds the event, when it should remove the overlay event.
  How can I check, if the overlayResize method is bound to window element, to prevent duplicate bindings? something like:</p>
  
  <pre><code>    if(overlyResize is not bound to window)
          $(window).resize(overlayResize);
      else
          //do something else or do nothing;
  </code></pre>