Re: Attach Events to elements dynamically created by JavaScript

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello Pascal:

Because the onclick event bubbles up to parent elements, including the body element, you don't need to attach an onclick event handler to every element. Simply attach one to the body element. The first argument to your event handler is an IHTMLEventObj object; use this object's srcElement property to obtain the element that was clicked.

Matt
.



Relevant Pages