<div class="elastic">Текст</div>
<div class="elastic">Еще один текст</div>
<script>
var k = 0;
var npoz = next();
var allel = document.querySelectorAll("div.elastic");
var tm = setInterval(rubberBand, 100);
function next() {
var i = -1;
return function () {
i = i < 7 ? i + 1 : 0;
return [16, 18, 20, 22, 23, 22, 20, 18][i];
};
}
function rubberBand() {
if (k == 16) clearInterval(tm);
var fsize = npoz() + "px";
for (var j = 0; j < allel.length; j += 1) {
allel[j].style.fontSize = fsize;
}
k += 1;
}
</script>