Hello and thanks in advance, I iterated buttons in handlebars, but when I try to refer to them using Id I get no response. I assumed its because its an ID and IDs are unique, so creating multiple would break the code somehow but I tried with classes and it didnt work either. This is the iteration from the handlebars file
<div class="timeline-wrapper">
<ul class="timeline">
<li data-date="">
<span class="title"></span>
<div id="moment-dots" class="data show">
<h3 class="description"></h3>
<small class="date"> </small>
<p class="^details">
</p>
<button id="get-history">What else happened on this day ?</button>
</div>
</li>
and here is the event listener I used as a click event to log "clicked" when clicked
function getValue (event) {
if(event.target.id === "get-history"){
console.log("clicked")
}
}
var gethistory = document.querySelector("#get-history");
gethistory.addEventListener("click", getValue);
Tried using classes instead of IDs.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/bHEvten
Comments
Post a Comment