I have a row of results: name, amount and I want to add a X at the end of the row allowing deletion of the entire row.
I gave only one row here, for brievity. There are many and I though of putting this in a for
.
This is my html :
let lignesRecurrentes = document.getElementsByClassName('ligne_recurrente')
for (var i = 0; i < lignesRecurrentes.length; i++) {
let ligneRecurrente = lignesRecurrentes[i]
let id = ligneRecurrente.id.replace('ligne_','')
let croix = document.getElementById('suppr_recurrente_'+id)
croix.addEventListener('click', function(){
console.log(croix.innerHTML)
}
)}
<div class="ligne_recurrente" id="ligne_3">
<span class="intitule" id="intitulerec_3">Cousteau</span>
<span class="montant">
<span class="chiffre_recur" id="montant_3">396,00</span>
<span class="euro">€</span>
<span id="suppr_recurrente_3 " > X</span>
</span>
</div>
<div id="smalrec_3"></div>
How come croix
is null? Can't add eventListerner on null?