0

I have this code for a hover effect, it was working, but now won't. jQuery is working, but events from jquery aren't...

$(document).ready(function () {
            $("#logoimg").hover(function () {
                $("#logoimg").attr("src", "Media/imgover.png");
                $("#logoimg").animate({ width: 420 }, 300);
            }, function () {
                $("#logoimg").attr("src", "Media/imgout.png");
                $("#logoimg").animate({ width: 400 }, 300);
            });
        });
4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Airshow
0

Not much to go on, short off the fact you want some image to be swapped and animate the width when the mouse is over. Please put up a link or more code.

0

I have tried the below code and it works fine.

<img id="logoimg" src="4.gif" width="50">
<script>
 $(document).ready(function () {
            $("#logoimg").hover(function () {
                $("#logoimg").attr("src", "4-roll.gif");
                $("#logoimg").animate({ width: 220 }, 300);
            }, function () {
                $("#logoimg").attr("src", "4.gif");
                $("#logoimg").animate({ width: 50 }, 300);
            });
        });
</script>

Edited by haleel: n/a

0

Eternity,

First, the code will simplify to :

$(document).ready(function () {
	$("#logoimg").hover(
		function () {
			$(this).attr("src", "Media/imgover.png").animate({ width: 420 }, 300);
		}, 
		function () {
			$(this).attr("src", "Media/imgout.png").animate({ width: 400 }, 300);
	});
});

Secondly, did it work locally then stop working after FTPing to a remote host?

If so then look to see if the "Media" directory became "media". FTP clients can, depending on settings, convert file names and directory names to lower case.

If that's ok, then I would suspect that some other piece of javascript/jquery is hijacking the "mouseenter" and "mouseleave" events.

If you're really unlucky then you're a victim of unwanted bubbling, which can be difficult to track down and even harder to cure.

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.