JavaScript
- 2 ответа
- 0 вопросов
2
Вклад в тег
$(document).ready(function(){
var i = 1;
$('.nav-top__list a').each(function(){
$(this).attr('id','number'+i);
i++;
})
var text = ["Welcome", "Hi"];
var counter = 0;
// let elem = document.getElementById("number3");
// var inst = setInterval(change, 2000 , elem );
let elem2 = document.getElementById("number2");
var inst2 = setInterval(change, 2000 , elem2 );
// elem.innerHTML = counter;
function change(elem) {
elem.innerHTML = text[counter];
counter++;
if ( counter == text.length ) {
counter = 0;
}
}
})