Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery mouse event occurring many times, want it only once
    primarykey
    data
    text
    <p>I'm trying to create a JQuery slider and I've hit a roadblock. I'm new to both Javascript and JQuery however. Here is my code -</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Experimentation&lt;/title&gt; &lt;style type="text/css"&gt; #container { overflow: hidden; height: 200px; width: 200px; } #box { width: 200px; height: 200px; background-color: gray; z-index: 10000; position: relative; } #information { position: absolute; width: 200px; height:200px; background-color: black; opacity: 0.2; top: 150px; color: #FFF; } #information h3 { margin: 3px 3px; text-align: center; } &lt;/style&gt; &lt;script type="text/javascript" src="jquery-1.4.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var topInitial = "0"; var topAfter = "150px"; $(function() { /* $("#box").mouseover(function(){ $("#information").css("top",topInitial); }); $("#box").mouseout(function() { $("#information").css("top",topAfter); }); }); */ $("#box").mouseover(function() { $("#information").animate({ top: 0 }, "slow"); }); $("#box").mouseout(function() { $("#information").animate({ top: 150 }, "slow"); }); //New Code $("#container").click(function() { $("#container").animate({ margin-left: 30}, "slow"); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="container"&gt; &lt;div id="box"&gt; &lt;div id="information"&gt; &lt;h3&gt; Criminal Penguins Having a Ball &lt;/h3&gt; &lt;p&gt; You have never seen something like this before!&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My problem is, the mouseover event is happening many times. Can someone tell me how to rectify this issue? Another important query, since I've only begun to code I'm sure I'll hit some roadblocks in the future as well. Should I then create a new thread with the modified code or will editing this thread work? Please help! :)</p> <p>Update: I've just added some new code in my Javascript. I want to move the element to the right by 30px. Is this the way to accomplish this task? </p>
    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.
    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