I'm working on a counter that can either count backwards or in ascending order based on requirements. The counter is functioning correctly, but I want to add text to accompany each number as it counts. The issue is that the text changes every time there's a change in the countdown. How can I modify the inner HTML of only part of the content without affecting the entire display? I need the text to remain constant.
Here is the HTML and JS code:
<div class="container">
<div class="number mt-3">100 **[I WISH TO INSERT TEXT HERE]** </div>
</div>
JS
const numberEl = document.querySelector('.number');
let startNumber = parseInt(numberEl.innerHTML);
const endNumber = 0;
const ticker = setInterval(() => {
numberEl.innerHTML = startNumber--;
if(startNumber === endNumber - 1) {
clearInterval(ticker);
}
}, 200);
You can also access the codepen example here: https://codepen.io/kenkozma17/pen/XWdbdrd