jQuery Animated Rollover

by Matt 26. December 2008 14:35

Here is an example of how to animate the rollover event of an element using jQuery:


<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script src="jquery.color.js" type="text/javascript"></script>

$(document).ready(function()
{
    $(".menuButton").hover(
        function()
        {
            $(this).animate(
                {
                    backgroundColor: "#9D9D9D"
                }, 300);
        },
        function()
        {
            $(this).animate(
                {
                    backgroundColor: "#BEBEBE"
                }, 900);
        }
    );
});

The above code will select all elements that use my "menuButton" CSS class.  This can be any class name, or you can select elements by id, etc.

To be able to set the background color in the animate method, you will need the following jQuery plug-in: http://plugins.jquery.com/project/color.

Comments

7/6/2010 9:02:06 AM #

Great article, this has to be THE single best article online.. thanks dude!

essay writing tips

7/6/2010 3:53:20 PM #

Hello. This is kind of an "unconventional" question , but have other visitors asked you how get the menu bar to look like you've got it?

Ayesha Antczak

7/11/2010 10:53:49 PM #

I wish I understood all this...

Basement Dehumidifiers

7/14/2010 9:00:45 PM #

thanks for sharing the code

Nike Air Force

7/29/2010 4:34:39 AM #

Thank you for this wonderful posts. Really made my spare time one pleasant experience.

podlozky na stol

8/19/2010 12:08:37 PM #

Man, I've been looking all over for this stuff.  Thanks.

wpia

8/28/2010 4:39:21 PM #

Quite absorbing. I'd absolutely like to read more about this. Does anybody have any advice where I can acquire some further resources? Appreciate it.

phentermine

8/30/2010 10:40:57 PM #

Intimately, the post is really the sweetest on this worthy topic. I harmonise with your conclusions and will thirstily look forward to your  forthcoming updates. Just saying thanks will not just be adequate, for the great lucidity in your writing. I will immediately grab your rss feed to stay informed of any updates. Genuine work and much success in your business efforts!

Jasmine

9/1/2010 9:32:03 PM #

Hermes Kelly Bag is the name of the actress Princess Grace Kelly . It was directed by an individual craftsman about 18 hours of hard work. The skin is inserted into the plant, which was previously set to a perfect symmetry and ready for the magic of the expert at the end of the Ladies Fashion Handbags. The material to coat the skin of goats and the first part of sewing used.

Ladies Fashion Handbags

Add comment




biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.0.7
Original Theme by Mads Kristensen | Modified by Crafty Coders