example.js
function(evt, id, fnc) {
    var elem = $(id);
    if (elem.addEventListener)  // W3C DOM
      elem.addEventListener(evt, fnc, false);
    else if (elem.attachEvent) { // IE DOM
      elem.attachEvent('on' + evt, fnc);
    }
    else { // No much to do
      elem[evt] = fnc;
    }
  }
function(evt, id, fnc) {
    var elem = $(id);
    if (elem.addEventListener)  // W3C DOM
      elem.addEventListener(evt, fnc, false);
    else if (elem.attachEvent) { // IE DOM
      elem.attachEvent('on' + evt, fnc);
    }
    else { // No much to do
      elem[evt] = fnc;
    }
  }
function ( evt , id , fnc ) { var elem = $ ( id ) ; if ( elem . addEventListener ) // W3C DOM elem . addEventListener ( evt , fnc , false ) ; else if ( elem . attachEvent ) { // IE DOM elem . attachEvent ( 'on' + evt , fnc ) ; } else { // No much to do elem [ evt ] = fnc ; } }
add event handler
@param {string} evt
@param {string} id
@param {function} fnc
add event handler