Note that there are some explanatory texts on larger screens.

plurals
  1. POimage overlay on hover javascript
    text
    copied!<p>i am trying to display additional info over an image by using two overlay images. on mouse hover overlay1 will be displayed at the top left corner of the main-image and overlay2 will be at bottom right..</p> <p>when i try this to do on a single image it works fine.. but as i get on to do it on gallery of images the overlay images displays at the top-left and bottom-right section of the screen..</p> <p>i want the images to be overlay-ed on the respective main-images..</p> <p>here is the html-</p> <pre><code>&lt;div id="WhizIt"&gt; &lt;div id="btpanelexsmall"&gt; &lt;h3&gt;Heading1&lt;/h3&gt; &lt;ul &gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="image/" class="wit"/&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;&lt;br&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;&lt;img src="images/arrow1.jpg" class="wit" /&gt;&lt;img class="overlay" src="image/top-left.jpg"/&gt; &lt;img class="overly" src="image/bottom-right.jpg"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>the script is-</p> <pre><code>&lt;script src="js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('ul li').mouseenter(function() { $(this).find(".overlay").show(); $(this).find(".overly").show(); }); $('ul li').mouseleave(function() { $(this).find(".overlay").hide(); $(this).find(".overly").hide(); }); }); &lt;/script&gt; </code></pre> <p>and the css-</p> <pre><code>.WhizIt li{position:relative; float:left; padding-left:5px; list-style:none;} .overlay { position:absolute; height:50px; width:150px; top:0; left:0; display:none;} .overly { position:absolute; height:50px; width:150px; bottom:0; right:0; display:none;} #btpanelexsmall{height:390px; margin:0px; padding:0px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; /* future proofing */ border:2px solid yellow; background: #f0f0f0;} </code></pre> <p>i have many galleries on my page!! thanks in advance</p>
 

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