Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Fading Problem
    primarykey
    data
    text
    <p>I have a menu which has 8 pictures and I want to write a fade effect for them. I want to show the name of the menu when the mouse goes over it, and hide it when mouse goes out. Here is my code for two of my menu items:</p> <pre><code>$(".menu_account").mouseover(function(){ $("#menu_name").html('first'); $("#menu_name").fadeIn('slow', function(){ $(".menu_account").mouseout(function(){ $("#menu_name").fadeOut('slow', function(){}); }) }); }); $(".menu_myposts").mouseover(function(){ $("#menu_name").html('second'); $("#menu_name").fadeIn('slow', function(){ $(".menu_myposts").mouseout(function(){ $("#menu_name").fadeOut('slow', function(){}); }) }); }); </code></pre> <p>My problem is when I am on the first item and the name has been appeared, when I move the cursor to the second item before the first fades out, the name's innerHTML changes and it gets ugly. I want to wait for fading out to be completed and start again. I really appreciate any help. thanx.</p> <p>Here is my full code: HTML :</p> <pre><code>&lt;div id="menu"&gt; &lt;a class="menu_account"&gt;&lt;/a&gt; &lt;a class="menu_myposts"&gt;&lt;/a&gt; &lt;a class="menu_allposts"&gt;&lt;/a&gt; &lt;a class="menu_favorites"&gt;&lt;/a&gt; &lt;a class="menu_follow"&gt;&lt;/a&gt; &lt;a class="menu_logout"&gt;&lt;/a&gt; &lt;a class="menu_help"&gt;&lt;/a&gt; &lt;a class="menu_contact"&gt;&lt;/a&gt; &lt;/div&gt; &lt;div style="height:20px;width:200px;margin:0 auto;text-align:center;"&gt; &lt;div id="menu_name" style="font-size:30px;color:#A1A1A1;display:none;"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>JS :</p> <pre><code>$("#menu").ready(function(){ $(".menu_myposts").hover( function () { $("#menu_name").html('first'); $("#menu_name").fadeIn('slow', function(){}); }, function () { $("#menu_name").fadeOut('slow', function(){}); } ); $(".menu_myposts").hover( function () { $("#menu_name").html('second'); $("#menu_name").fadeIn('slow', function(){}); }, function () { $("#menu_name").fadeOut('slow', function(){}); } ); }); </code></pre> <p>Correct JS:</p> <pre><code>$(".menu_item").hover( function() { $("#menu_name").html($('#' + this.id + '_name').html()); $("#menu_name").stop(true, true).fadeIn(); }, function() { $("#menu_name").stop(true, true).fadeOut(); } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload