I am using jquery and what I want to do here is to be able to set the image that will show up based upon the link that is being hovered to.
<script type='text/javascript'>
$(function(){
$('img').hide();
$('a').mouseenter(function(){
var currentimg= $(this).html();
alert(currentimg);
$("img[src=currentimg.jpg]").show(); //I want to use currentimg variable here for the name of the jpg file
});
$('a').mouseleave(function(){
$('img').hide();
});
});
</script>
You can just concatenate the string for use, for example:
Just to note, there’s also a
.hover()shortcut for.mouseenter(handler).mouseleave(handler), like this: