By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

adding an event handler to a variable

P: 178
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??
Jul 4 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,654
You can add it like this.
Expand|Select|Wrap|Line Numbers
  1. img.onmousedown = function () {
  2.     doABC('x','y','z');
  3.     doXYZ();
  4.     alert('mouse down');
  5. };
Not only onmousedown, but you can add any event like this.
Jul 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.