javascript - How do I fade out this fade on mouseleave? -


i want able fade out div got faded in, can't work. have following code:

    $(document).ready(function() {         $('.upgrade').mouseenter(function() {             var modal = $(this).data('modal');             // alert(modal);             $('.' + modal).fadein(200);         }).mouseleave(function() {             $('.' + modal).stop().fadeout(200);         });     });      <div class="upgrade" id="upgrade-1" data-modal="bonus">        <!-- text -->     </div>     <div class="bonus">       <!-- bonus product text -->    </div> 

you need delcare modal outside mouseenter function

$(document).ready(function() {      var modal="";//declare here     $('.upgrade').mouseenter(function() {          modal = $(this).data('modal');         $('.' + modal).fadein(200);     }).mouseleave(function() {         $('.' + modal).stop().fadeout(200);     }); }); 

demo


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -