1, Eleobj.addeventlistener (eventname,handle,usecapture);
Eleobj:dom elements;
EventName: Event name. Note that the event name here does not have "on", such as mouse click event DoubleClick, mouse double click event, mouse move into event mouseover, mouse move out event mouseout, etc.
Handle: Event handle function, which is the function used to handle the event;
Usecapture:boolean type, whether to use capture, generally with false;
2, Eleobj.attachevent (Eventname,handle);
Eleobj:dom elements;
EventName: Event name. Note that, unlike AddEventListener (), the event name here has "on", such as mouse click event onclick, mouse double click event OnDoubleClick, mouse move into event onmouseover, mouse move out event onmouseout, etc.;
Handle: Event handle function, which is the function used to handle the event;
Note: AddEventListener () is a standard method of binding event listener functions, supported by the publisher, Chrome, FireFox, Opera, Safari, This function is supported by IE9.0 and above, but IE8.0 and the following versions do not support this method, and it uses attachevent () to bind the event listener function. Therefore, this method of binding an event must handle browser compatibility issues.
JavaScript binding events AddEventListener and Attachevent