I've been attempting to modify the image src when hovering using JQuery. I'm currently working in Brackets, and when I preview it live in Chrome, everything seems fine. However, when I try to open the file directly in Chrome or IE, it doesn't function correctly.
Here is my code:
$("#logo img").hover(
function(){
$("#logo img").attr("src","/images/img1.gif");
}, function() {
$("#logo img").attr("src","/images/img2.gif");
});
Edit: This is the HTML code:
<div id="logo">
<img id="logo-img" src="images/img1.gif" alt="logo">
</div>
The img tag has an id "logo-img", but even targeting this id directly hasn't solved the issue:
$("#logo-img").hover(
function(){
$("#logo-img").attr("src","/images/img1.gif");
}, function() {
$("#logo-img").attr("src","/images/img2.gif");
});
Your assistance would be greatly appreciated.