Untitled
unknown
plain_text
10 months ago
332 B
11
Indexable
<div>
<p>Apples: <span id="apples">10</span></p>
<button onclick="decrease('apples')">-1</button>
</div>
<script>
function decrease(id) {
let el = document.getElementById(id);
let num = parseInt(el.innerText);
if (num > 0) el.innerText = num - 1;
}
</script>
}Editor is loading...
Leave a Comment