I'm getting an error when setting on click to the dynamically added html elements in jquery. First of all i should say that i searched alot in this community but i get more confused .
here is my code :
var data = ['element1','element2','element3'] ;
var html = '' ;
for(let i = 0;i<data.length ; i++){
const element = data[i];
html += '<li id="'+element+'">'+element+'</li>' ;
}
I Want to add different click functions to every list item in this code using ids . any suggestions will be helpfull , thanks to this great community .
, check the target of the event and depending on its id do different things. Look on SO for "event delegation"
– Fabrizio Calderan Feb 05 '19 at 09:28