adding an event handler to a variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cleary1981
    New Member
    • Jun 2008
    • 178

    adding an event handler to a variable

    I am completely confused here. My application generates an image when a button is clicked and sets the appropriate attributes (height, width id, etc) the problem I am having is that each image that is created must have an onmousedown event handler added. Since these images are created in the script I don't see how I can do this.

    Any ideas??
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    You can add it like this.[CODE=javascript]img.onmousedown = function () {
    doABC('x','y',' z');
    doXYZ();
    alert('mouse down');
    };[/CODE]
    Not only onmousedown, but you can add any event like this.

    Comment

    Working...