In my html body I am using a javascript that writes and changes a line of text in my div, with ID "moto", every 5 seconds.
var text = ["TEXT 1","TEXT 2","TEXT 3","TEXT 4"];
var counter = 0;
var elem = document.getElementById("moto");
ChangeFunction();
setInterval(ChangeFunction, 5000);
function ChangeFunction() {
elem.innerHTML = text[counter];
counter++;
if(counter >= text.length) { counter = 0; }
}
#moto{
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
<div id="moto"></div>
Do I need to apply some java fade-in fade-out? I would rather use CSS...
innerHTMLthere's nothing to fade. You first fade out the oldtext, then put the newtext in, then fade it in. (note: Javascript has nothing to do with Java despite the name similarity)