I have a very simple banner change script:
document.getElementById("car_head").innerHTML = carousel开发者_运维知识库[carousel_num][0];
document.getElementById("car_text").innerHTML = carousel[carousel_num][1];
document.getElementById("car_pic").src = carousel[carousel_num][2];
This changes the content of my header on a timer.
How can I add a simple animation to it? Would adding a fade in/out animation be different than adding a slide in/out animation?
Thanks,
You would need to loop through it with some form of an animation loop that gradually changes the value you want (alpha, x/y, whatever). For example:
var change = function() {
x -= 10;
y -= 2;
styleThese();
if (x > 10 && y > 0) {
setTimeout(change, 20);
}
}
change();
Obviously this code doesn't really work. Just work off of that basic idea.
精彩评论