Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery::when I use fadeIn() my page moves its focus!
    primarykey
    data
    text
    <p>I have a simple HTML page, and some javascript using the basic $(#element).fadeOut method from jQuery on mouseover event. I also use the $(#element).hide() method.</p> <p>But my page focus shifts up! Meaning: if I scroll down a bit, and mouseover the element (which toggles the script), script is executed well, but my scroller goes up immediately and I lose where I had scrolled to.</p> <p>How can I fix this? </p> <p>Here's my code:</p> <pre><code>function swapElements(unfadeElement, how, callbackExecute) { if (unfadeElement==swapper.active) return; if (how!="slow" &amp;&amp; how!="fast") return; var fadeElement=swapper.active; $("#" + fadeElement).hide(); $("#" + unfadeElement).fadeIn(how,callbackExecute); swapper.active=unfadeElement; } </code></pre> <p>The fadeIn function:</p> <pre><code>function fadeInElement(element, how, callbackExecute) { //pre: how is "slow" or "fast" if (how!="slow" &amp;&amp; how!="fast") return; $("#"+element).fadeIn(how, callbackExecute); } </code></pre> <p>A sample script call:</p> <pre><code>&lt;a href="javascript: void(0)" onmouseover="fadeIn('carpets','slow',void(0))"&gt; Carpets&lt;/a&gt; </code></pre> <p>EDIT: Added some of the HTML code</p> <pre><code> &lt;div id="menuDiv"&gt; .................... &lt;div id="menu1" class="menuDivLink"&gt; &lt;a href="javascript: void(0)" onmouseover="swapper.fadeIn('carpets','slow',void(0))"&gt; Carpets&lt;/a&gt; &lt;/div&gt; &lt;div id="menu2" class="menuDivLink"&gt; &lt;a href="javascript: void(0)" onmouseover="swapper.fadeIn('rugs','slow',void(0))"&gt;Rugs&lt;/a&gt; &lt;/div&gt; &lt;div id="menu3" class="menuDivLink"&gt; &lt;a href="#" onmouseover="swapper.fadeIn('windows','slow',void(0))"&gt;Link1&lt;/a&gt; &lt;/div&gt; ............ &lt;/div&gt; </code></pre> <p>Also, could some of my css cause this problem? Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    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.
    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