Let say I have 5 element from PHP query (so it is dynamic)
Illustrated below:
element 1 class=element id=id_1
element 2 class=element id=id_2
element 3 class=element id=id_3
element 4 class=element id=id_4
element 5 class=element id=id_5
we ussulay use jquery event by knowing their class or id, but in this case, we don't know exactly their id
$("#id_3").click(function(){ //in this case we have known we want to add event when we click id_3
});
but how to deal with dynamic element from PHP query?
for example, how can we know that we click on element 3 with id_3?
What mus we fill in $(????).click(); ??
when I use class, how can I know which id I reference from the class clicked?
No comments:
Post a Comment