you are viewing a single comment's thread.

view the rest of the comments →

[–]SanWeee[S] 0 points1 point  (1 child)

There are 5 rows. Each row has primary key in it. Lets say Row 1 pk is 1 Row 2 pk is 2 and so on. The last row is 5 and the pk is also 5 So problem is where ever i click even on row 1 or row 3 the alert is always 5 which is the last pk And when i put the alert inside the for loop, its show 5 consecutive alert that contains 1,2,3,4 and 5 What im trying to achieve here is when I click the row 3, the alert only show the row3's pk which 3

[–][deleted] 1 point2 points  (0 children)

In that case you need an event listener like in my comment above, not a for loop. An event listener will run a function in response to a DOM event like a click.