javascript - Flickering replacement image -


i have added jquery in order display .png image blue bar across bottom text, hover on it, flickers alot, can't seem control it. on 6 images on homepage, link provided.

i've included associated html, css, javascript.

live url: http://bit.ly/pjp9fj

html

<div class="product-images">         <a href="http://coeval.mangdevelopment.co.uk/uploads/product-pdf/1-2.pdf" target="_blank">         <div>             <img id="main" src="<?php http_host ?>/images/index-products/index-product1.jpg" alt="" title="" />             <img id="overlay" src="<?php http_host ?>/images/thumbnail-overlay.png" alt="" title="" />             <span id="text">speed indicator displays</span>         </div></a> </div> 

css

#index-products-gallery .opp-angle .product-images div { position: relative; } #index-products-gallery .opp-angle .product-images #main { width: 222px; height: 160px; } #index-products-gallery .opp-angle .product-images #overlay { position:absolute; width: 222px; height: 160px; top:0; left:0; display:none; margin-left: 0; } #index-products-gallery .opp-angle .product-images #text { position:absolute; bottom: -160px; left: 10px; color: #fff; font-weight: bold; font-family: calibri, candara, segoe, "segoe ui", optima, arial, sans-serif; font-size: 14px; display:none; z-index: 999; } 

javascript

<script type="text/javascript">     $(document).ready(function() {     $("#main").mouseenter(function() {                $("#overlay").show();                $("#text").show();     });     $("#main").mouseleave(function() {                $("#overlay").hide();                $("#text").hide();     }); }); </script> 

it due fact adding layer on top of image causes mouseleave event fire. apply mouse enter , leave events parent element.

also why using tons of ids, use class

html:

<div class="product-images">         <a href="http://coeval.mangdevelopment.co.uk/uploads/product-pdf/1-2.pdf" target="_blank">         <div>             <img class="main" src="<?php http_host ?>/images/index-products/index-product1.jpg" alt="" title="" />             <img class="overlay" src="<?php http_host ?>/images/thumbnail-overlay.png" alt="" title="" />             <span class="text">speed indicator displays</span>         </div></a> </div> 

javascript:

$(function() {     $(".main").parent().on("mouseenter", function() {         $(this).find(".overlay").show();         $(this).find(".text").show();     }).on("mouseleave", function() {         $(this).find(".overlay").hide();         $(this).find(".text").hide();     }); }); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -