Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Jquery animate

hi, i'm having trouble running the jquery animate function in my browser. All the other functions that i've tried seem to work, however this doesn't? I've imported the jqeury 2.1.1 version.

$('div').click(function () {
        $('div').animate({ color: "#348593" }, 1500);
}); 

2 Answers

Hi Kristoffer, color animations are not offered in the core library. Here's the plugin you'll need.

<script src="http://code.jquery.com/color/jquery.color-2.1.2.js"></script>

Oh, i wasn't aware of that. thank you. However, i was using it more as an example, since the animate function doesn't work for me at all. The code doesn't work even after importing the color plugin.

If you're using the click function, I think you'll need a button or something like this.

<button id="go">Go</button>
<div id="block">Hello!</div>
$( '#go' ).click(function () {
        $( '#block' ).animate({ color: "#348593" }, 1500);
});

my bad, i was using color instead 0f backgroundColor :).

Yeah, you can see the text change, but that color is difficult to see alone :smiley:

Here's some more examples of .click()