jQuery off when on was defined with anonymous function
<p>I have a function that registers an event handler with a callback that will receive only some of the event data.</p>

<p>My problem is I want to protect against the function registering multiple time by calling <code>.off</code> before <code>.on</code> but I'm not sure how to specify the callback to <code>.off</code> in this case as it has to be the same function used by <code>.on</code></p>

<p>For example:</p>

<pre><code>function myclick(elem, callback) {
  //elem.off('click', ???? ); // how should this be specified
  elem.on('click', function (e) {
     callback(e.target);
  }
}
</code></pre>

<p>I am looking for a general solution that is not jQuery dependent as this can happen with any library that provides on and off functionality.</p>