addEvent()作者:John Resig

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了addEvent()作者:John Resig相关的知识,希望对你有一定的参考价值。

  1. // addEvent() by John Resig
  2. // http://ejohn.org/projects/flexible-javascript-events/
  3. function addEvent ( obj, type, fn ) {
  4. if ( obj.addEventListener ) {
  5. obj.addEventListener ( type, fn, false );
  6. } else if ( obj.attachEvent ) {
  7. obj["e"+type+fn] = fn;
  8. obj[type+fn] = function ( ) { obj["e"+type+fn] ( window.event ); }
  9. obj.attachEvent ( "on"+type, obj[type+fn] );
  10. }
  11. }

以上是关于addEvent()作者:John Resig的主要内容,如果未能解决你的问题,请参考以下文章