Struggling to create simple image rollovers
Hello, I'm working on a navigation page where some images appear on the left / right of the text when the mouse hovers on a certain container. It's easier to understand if you just read the short code.
- $("#p1Control").hover(function()
- {
- $(".p1right_arrow1").animate({ opacity: 1.00 }, 500);
- $(".p1left_arrow1").animate({ opacity: 1.00 }, 500);
- });
- $("#p1Icon").hover(function()
- {
- $(".p1right_arrow2").animate({ opacity: 1.00 }, 500);
- $(".p1left_arrow2").animate({ opacity: 1.00 }, 500);
- });
-
- $("#p1Control").mouseout(function()
- {
- $(".p1right_arrow1").animate({ opacity: 0 }, 500);
- $(".p1left_arrow1").animate({ opacity: 0 }, 500);
- });
- $("#p1Icon").mouseout(function()
- {
- $(".p1right_arrow2").animate({ opacity: 0 }, 500);
- $(".p1left_arrow2").animate({ opacity: 0 }, 500);
- });
HTML
- <div id="player1" class="player">
- <p id="p1Control">
- <img class="p1left_arrow1" src="img/left_arrow.png"></img>
- Human
- <img class="p1right_arrow1" src="img/right_arrow.png"></img>
- </p>
- <p id="p1Icon">
- <img class="p1left_arrow2" src="img/left_arrow.png"></img>
- Image
- <img class="p1right_arrow2" src="img/right_arrow.png"></img>
- </p>
- </div>
Now, the rollovers work almost as expected. However when I move the mouse up and down the page quickly a few times the images start to appear and disappear on their own, and they'll stop functioning properly if I put my mouse back over the container. I am pretty sure the animations are stacking up and stopping the event handler (or whatever) from catching the hover because animations are still running.
Does anyone have any ideas?
Thanks!
Joe