August 31, 2010
How to animate text using JavaScript
Question by Hema
I want to implement animated text i.e. moving the text from bottom (half of the page) to the top like marquee. I don’t get any good code. Does any one know how this is implemented in JavaScript or jQuery or DHTML?
Thanks in advance
Answer by Cipi
Same code as the answer below but, it sets the TEXT location to be at half the page’s height, and then animates it to top:
//Calculate where is HALF of the page (half the window height)
var start_pos = screen.height/2;
//Set starting TOP location
$(".text").css("top", start_pos+"px");
//Animate to the END location, which is 0px
$(".text").animate({ top:0+"px" }, 5000, function() { alert("Animation Complete"); });