Answer the question
In order to leave comments, you need to log in
How to get div values?
There are 5 divs with text nodes inside:
<div class="counter">
<div class="count" data-num=''>1</div>
<div class="count" data-num=''>2</div>
<div class="count" data-num=''>3</div>
<div class="count" data-num=''>4</div>
</div>
Answer the question
In order to leave comments, you need to log in
setInterval(count => {
const
len = count.length,
val = `${+count.map(n => n.textContent).join('') + 1}`.padStart(len, 0).slice(-len);
count.forEach((n, i) => n.textContent = val[i]);
}, 50, [...document.querySelectorAll('.count')]);
$('.selector').each(function(){
$(this).text(+$(this).text() + 1);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question