
Is there a way to determine from which part of an HTML document a script was called, by getting, say, the ID of an element? Yes, there is. Take a look at the example in Figure 1. There are two buttons, each of which have script code that calls into a function named MyFunction. Inside of MyFunction is event.srcElement, which retrieves the particular element that triggered the initial event. Once you have this, you can get the caller's ID.
|