How to get the index when traversing registered events in js

1.jpg

Note: This way of writing is problematic.

The registration event is done after the page is loaded, but no event is fired at this time. The event trigger is triggered when the user clicks on the page, so when the user clicks, the event handler will be executed, then the i at this time has become 4, and the final result that pops up is i+1, That is 5, and the result of each element's popup is 5.

At this point the approach should be like this:

2.jpg

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324837905&siteId=291194637