This week I’m going to show you to make the best use of jQuery’s amazing animation features using just a few lines of code for each our examples. Did you know that you can use jQuery’s animation functions to create your very own progress-bar in less than 3 lines? or that you could use it to make your very own accordian in under 9 lines? Well, today I’m going to go through some examples of how to do these and a whole lot more.
First let’s start with some basics. What is the jQuery animate() feature?. The animate() feature allows you to create custom animations using a few lines of code – it’s key aspect is the object containing all of the style properties to be animated and to what end. Essentially this means that it allows you to specify what you want to animate and where you eventually want that item to appear. For example, if I have a div called "red" on what side of the screen, I can specify the end of the screen as an end-point and have it animate towards that point. I’m able to also say what property of the item I would like animated -eg. in the above case if I wanted to move the item towards the end of the screen..I would alter the marginLeft property from where it is right now to something larger. This is done as follows:
ShareRelated posts:
Related posts brought to you by Yet Another Related Posts Plugin.
RSS feed for comments on this post. TrackBack URL
October 29th, 2009 at 5:39 pm
Again, great article, Addy!
For some reason, your code snippets are showing line breaks with an extra graphic (green, swooshy arrow). It might confuse people.
Just my two cents! Thanks for another helpful article!
October 30th, 2009 at 12:14 am
I found your article through dzone – nice. I'll give you an "up" vote on there, but wanted to comment here as well. Great Job…
October 30th, 2009 at 12:27 am
Thanks! I looked into it and its because the lines are wrapping around due to my layout's width. I'll see if I can hack together a patch for the highlighter.
Appreciate the heads up :)
October 30th, 2009 at 12:27 am
Thanks! I'm glad you enjoyed the article.
October 30th, 2009 at 1:30 am
Thanks for good tips.
October 30th, 2009 at 7:33 pm
WOW! I was looking for a compact slideshow and ran across your site which really opened my eyes to the possibilities of JQuery. Great work. Thanks.
October 30th, 2009 at 7:35 pm
My pleasure!. Thanks for reading.
October 30th, 2009 at 7:36 pm
You're very welcome. I'm happy to see that my articles are helping other coders see how useful jQuery can be!
November 11th, 2009 at 2:31 am
Hi, I’m a newbie. I’m still learning hence I don’t have my website yet. Hopefully, I can create one soon with the JQuery you taught.
I’d like to know why when I click on your animation button of your exampes above, nothing happens. I have java turn on in my browser.
Please advise. tk.s