function listen(event, elem, func) {
elem = $(elem);
if (elem.addEventListener) // W3C DOM
elem.addEventListener(event,func,false);
else if (elem.attachEvent) { // IE DOM
var r = elem.attachEvent("on"+event, func);
return r;
}
else throw 'No es posible añadir evento';
}
------
Use:
------
listen(event, elem, func);