Reputation: 819
I'm trying to make a div that changes text every few seconds. I'm trying to do this in JavaScript only. I don't want to use jquery. The console isn't showing any errors, and I made a few alerts to test where the disconnect is but cannot find out what i'm doing wrong. Please help, and thanks in advance.
HTML
<div id="ss"></div>
JS
(function() {
var UIlogic = {
loadData: function() {
var ss_i = 0;
var ss_array = ["Reading","Redstone","Family","Engineering","Hockey"];
var ss_elem;
ss_elem = document.getElementById('ss').innerHTML;
function ssNext(){
ss_i++;
ss_elem.style.opacity = 0;
if(ss_i > (ss_array.length - 1)){
ss_i = 0;
}
setTimeout('ssSlide', 1000);
}
function ssSlide(){
ss_elem = ss_array[ss_i];
ss_elem.style.opacity = 1;
setTimeout('ssNext', 2000);
}
}
};
window.onload = function() {
UIlogic.loadData();
};
})();
Upvotes: 0
Views: 54
Reputation: 531
()
, I think - I never use it in this way.setTimeout(fct,100)
loadData
Upvotes: 2
Reputation: 3318
You never called your slide functions. Have a look at this to get started: http://jsbin.com/yutuji/1/
Upvotes: 2