JSFiddle - React, Tailwind, and code Playground
by Sergei Sokolov
HTML
<p>Наш контакт-центр</p>
<a
href="tel:80635859090"
id="phone-carousel"
data-phones="80635859090,80655859090,80665859090,84955555555"
>
8<span> 063 </span>585-90-90
</a>
<p>Работаем с 9 до 19 ежедневно</p>
JavaScript
/**
* для вопроса https://toster.ru/q/659529
* Как с 3 номеров сделать 1, с меняющимся тегом span?
*/
{
const el = document.querySelector('#phone-carousel');
const phones = el.dataset.phones.split(',');
let i = 0;
setInterval(() => {
const phone = phones[++i % phones.length];
const prefix = phone.substring(0, 1);
const code = phone.substring(1, 4);
const tail_a = phone.substring(4, 7);
const tail_b = phone.substring(7, 9);
const tail_c = phone.substring(9, 11);
el.innerHTML = `${prefix}<span> ${code} </span>${tail_a}-${tail_b}-${tail_c}`;
el.setAttribute('href', `tel:${phone}`);
}, 1000);
}