The following code does not work. That is, I am making an array with the values, but it does not work with the setTimeout.
I do not know what to do? Or I'm doing wrong the data interpretation.
The functionality is to change the text every 1 sec, but I can not make it work.
HTML:
<span class="title"></span>
JS:
var month = [
"One Month",
"Two Month",
"Three Month",
"Four Mounth"
];
var number = month.length;
function doSetTimeout(i) {
setTimeout(function() {
$(".title").text(month[i]);
}, 1000);
}
for (var i = 0; i < number; i++) {
doSetTimeout(i);
}
JSFIDDLE: