title: jQuery pass var between event
body: <p>I try to understand how I can pass a DOM betweenjQuery events.</p>
  
  <p>For example, I created a simple tooltip plugin and it appends on <code>mouseenter</code> a div and I would like to remove on <code>mouleave</code> the same appended div. However if I have multiple elements which are hovered I can't select the right element to remove.</p>
  
  <p>Here a simple example code:</p>
  
  <pre><code>    $(this).on('mouseenter', function() {
  
          $('&lt;div class="'+options.class.split('.').join('')+'"&gt;&lt;/div&gt;').appendTo('body').addClass(options.hoverClass.split('.').join(''));
          $tooltip = $(document).find(options.class).last();
  
      }).on('mouseleave', function() {
  
          $tooltip.first().removeClass(options.hoverClass.split('.').join(''));
          setTimeout(function() {
              $tooltip.first().remove(); // remove the right DOM appended for the element hovered
          },400);
  
      });
  </code></pre>
  
  <p>original code: <a href="http://fiddle.jshell.net/Lw4behcu/1/" rel="nofollow">http://fiddle.jshell.net/Lw4behcu/1/</a></p>
  
  <p><strong>EDIT</strong>: Working fiddle: <a href="http://fiddle.jshell.net/Lw4behcu/2/" rel="nofollow">http://fiddle.jshell.net/Lw4behcu/2/</a></p>