JQuery hover fadeIn / fadeOut problem

http://www.izrada-weba.com/orso When you hover over the link "NENATKRIVENA TERASA ..." the submenu and the image disappear together. The submenu fades using some loaded script, and the image above fades out using my code:

$(document).ready(function () {
   $("#slika1").hide();

  $("#test,#submenu2").hover(
      function () {
       $("#slika1").fadeIn();
      }, 
      function () {
         $("#slika1").fadeOut();
      }
    );       
});

When the mouse is over the link, than the image disappears, and when the mouse moves to the submenu, the image disappears and disappears again ... I know why this is, but I do not know how to make it non-fading when moving the mouse directly from the link to submenu. Are there any solutions for this?

Thanks, Ile

+3
source share
2 answers

stop() .
mouseover:

$("#slika1").stop().fadeIn();


Edit:
, , (. ile). , jQuery, . , - , .
, fadeTo(); , , :

$(document).ready(function () {
  $("#slika1").fadeTo(0,0);

  $("#test,#submenu2").hover(
    function () {
      $("#slika1").stop(true).fadeTo("normal",1);
    }, 
    function () {
      $("#slika1").fadeTo("normal",0);
    }
  );       
});
+16

fadeIn() , fadeOut() , fadeIn() , . . , .

$("#mydiv").stop().hide().fadeIn(450);
+1

Source: https://habr.com/ru/post/1721555/


All Articles