Here is my EJS code: when I click on any iterated button it only changes first element's value. But I want to make other element to change as well. What's wrong with it?
<% for(let i=0; i<10; i++){
%> <h2 id="value">0</h2> <button onclick="btnHandler()">click to change</button> </h1> <%
} %>
<script>
let val = document.getElementById('value');
let start = 0
function btnHandler(){
val.innerHTML = `${start++}`
}
</script>
I try to to change value of iterated element using iterated button with onlclick but it only affect first elements. I expect to change other element as well.