Posted By

damarev on 11/26/06


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

rnrleachryan
vali29
wirenaught


add event listener


 / Published in: JavaScript
 

  1. function listen(event, elem, func) {
  2. elem = $(elem);
  3. if (elem.addEventListener) // W3C DOM
  4. elem.addEventListener(event,func,false);
  5. else if (elem.attachEvent) { // IE DOM
  6. var r = elem.attachEvent("on"+event, func);
  7. return r;
  8. }
  9. else throw 'No es posible aƱadir evento';
  10. }
  11.  
  12.  
  13. ------
  14. Use:
  15. ------
  16. listen(event, elem, func);

Report this snippet  

You need to login to post a comment.