Intercept event on an image JS has put itself
Then, my kingdom game with rats in JS is on the road. I even started to make it have "turns". Work well (thanks again for the innerHTML solution, guys).
Actually, to wait between turns, i'm using an "alert box". But i want something else.
What i'm wanting is :
- The script put an image "next turn" on the page, with a createElement.
=> work well, the image appear.
Then i put a loop for the turns.
=> work well too. You can choose starting turn, ending turn, increment, and if there is a turn "0" (when starting is negative and ending positive, by example. You know year 0 didn't exist, of course).
My problem is now :
How do my script can intercept an event (a click will do) on a image it put itself in the page ?
Of course, i searched for explanations and tutorials, but those i found speak of an "onclick" on the image calling a new JS script, and i don't know if trading data between scripts is even possible.
An idea ?