I want to implement animated te开发者_运维百科xt 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
use jquery
$('#mydiv').animate({
top: 0
}, 5000, function() {
// Animation complete.
});
Check the demo here
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"); });
精彩评论