I have created a class, I am dynamically filling the statement in the template string with a loop, one of them is a picture, and I want to add an event listener click to the picture so that by clicking on this photo something can happen and how much is it possible?
my class:
class Statement {
constructor(title,image,description,price){
this.title=title;
this.image=image;
this.description=description;
this.price=price;
}
}
const statement16 = new Statement('element',"https://smenterprise.ge/wp-content/uploads/2019/09/IMG-20190902-WA0035.jpg","ist a good condition",199);
const statementsArray=[statement1,statement2,statement3,statement4,statement5,statement6,statement7,statement8,statement9,statement10,statement11,statement12,statement13,statement14,statement15,statement16]
const appendStatement=(statement)=>{
const statementTemplate=`
<div class="statement">
<p class="statementTitle"> ${statement.title}</p>
<img class="statementImg" src=${statement.image} alt="">
<p class="description">${statement.description} </p>
<p class="productPrice">${statement.price} ₾ </p>
</div>
`
productList.innerHTML+`enter code here`=statementTemplate
}
const appendAllStatements=(statements)=>{
for(const statement of statements){
appendStatement(statement);
}
}