Posted By

noah on 07/20/07


wrapper event crossbrowser browser DOM click dhtml ui trigger tools chrome bubble propagation ecom clicking container simulate onebigeventhandler onebigone encapsulation

Versions (?)

click on an element across browsers

 / Published in: JavaScript

If you have assigned an event handler to a container, you might want to remotely trigger it as if a child of the container had been clicked. That is, you might want to manually set the target of the 'event' object that is passed to the event handler on the container. This helps to keep the number of event handlers down.

  1. //assuming that 'menu' has an appropriate onclick handler:
  2. function simulateClick( itemToClick, menu) {
  3. if ( ! ) {
  4. //== Non-IE:
  5. menu.onclick({target: itemToClick});
  6. } else {
  7. //== IE:
  9. }
  10. }

Report this snippet  

You need to login to post a comment.