I'm trying to make a functionality when a user hovers over an image then an anchor element will appear The user can then click on the anchor tag to follow the link. When the user isn't hovering the image, it disappears.
Making the anchor tag appear when I hover over the image works fine, but when I hover over the anchor tag, it disappears. The reason is because when the anchor element appears, the mouse is no longer hovering over the image directly. Soooo basically, my tactic doesn't work. Could someone suggest a method?
Here's my method below: http://jsfiddle.net/5z4RL/
HTML // I have a div with an unordered list. Each li has an img and an anchor
<div id="img_container">
<ul>
<li>
<img src="img/first.jpg" width="260px" height="260px">
<a href="#">Click Here To Visit </a>
</li>
<li>
<img src="img/second.jpg" width="260px" height="260px">
<a href="#"> Click Here To Visit </a>
</li>
<li>
<img src="img/third.jpg" width="260px" height="260px">
<a href="#"> Click Here To Visit </a>
</li>
</ul>
</div>
JQUERY
$(document).ready(function(){
$("#img_container img").hover(
function(){
$(this).next().css("visibility","visible");
}, function(){
$(this).next().css("visibility","hidden");
}
);
});// end of ready