I often need to add events to an element inside a JavaScript loop. If you’ve ever done this before, you know that it wont work unless you change the syntax properly, the event will always fire on the last item in the loop. In this article I will show you the simple concept of using a closure around the event to make it work properly. See the closure.