How do I animate picture in jQuery when i rollover it?
I am trying to use jQuery on wordpress to animate a picture when the mouse hovers over it. There are a group of 5 photos..and it would be nice not to make a function for each one. This code below does NOT work when I use the ID of the image for the hover funtion’s ID, but when I use it for a div i created, it animates the picture perfectly. Only thing is i need a mouseOut function too, but not sure how to go about that either. I tried placing the picture inside of the div and maing a rollover effect for that div to affect the picture, however that doesnt work either. This is what I have:
$(“#topbarimg”).hover(function(){
$(“#topbarimg”).animate({
width: “120px”,
height: “120px”
}, 750 );
}) ;
Any help is appreciated!
Thanks!
Thanks ! This worked! But I still was wondering about the mouseout function.
- Category: JQuery Questions
I am trying to use jQuery on wordpress to animate a picture when the mouse hovers over it. There are a group of 5 photos..and it would be nice not to make a function for each one. This code below does NOT work when I use the ID of the image for the hover funtion’s ID, but when I use it for a div i created, it animates the picture perfectly. Only thing is i need a mouseOut function too, but not sure how to go about that either. I tried placing the picture inside of the div and maing a rollover effect for that div to affect the picture, however that doesnt work either. This is what I have:
$(“#topbarimg”).hover(function(){
$(“#topbarimg”).animate({
width: “120px”,
height: “120px”
}, 750 );
}) ;
Any help is appreciated!
Thanks!
Thanks ! This worked! But I still was wondering about the mouseout function.
Other Questions
Login
Search
Recent Comments
- dgdg_dasdad on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- Anas Imtiaz on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- David D on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- Wolfman on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- TnT on Having a Jquery PHP problem?


Greg
Posted 11 months ago
Hi Richie,
jQuery is fun when it works, but a real pain it doesn’t do what you expect.
I had trouble using jQuery in WordPress until I replaced $ with jQuery. This was necessary because WordPress uses jQuery as well.
This is the format I use for my functions: jQuery(“foo”).bar({, etc.
Depending on your application, you may need to wrap your functions inside this block:
$(document).ready(function() {
// Your functions
});
This ensures that the page is fully loaded, giving you access to all of the page elements.
If you’re not already using it, FireBug is a handy tool to have when debugging JS in WordPress.
Hope this helps.