Mainly solved
Browser compatibility, now compatible with IE6 7 8 ff Google (nonsense)
In IE, this points to a problem.
Go directly CodeRight!
Copy codeThe Code is as follows: var bind = function (object, type, FN ){
If (object. attachevent) {// IE browser
Object. attachevent ("On" + type, (function (){
Return function (event ){
Window. event. cancelbubble = true; // stop time bubble
Object. attachevent = [FN. Apply (object)]; // ---- Here I want to talk about
}
}) (Object), false );
} Else if (object. addeventlistener) {// other browsers
Object. addeventlistener (type, function (event ){
Event. stoppropagation (); // stop time bubble
FN. Apply (this)
});
}
}
// The following is a click event for the aaa id.
BIND (document. getelementbyid ("AAA"), "click", function () {alert ("this is the ID of the button you clicked" + this. ID + "this is the bound 1st functions ")});
BIND (document. getelementbyid ("AAA"), "click", function () {alert ("this is the ID of the button you clicked" + this. ID + "this is the bound 2nd functions ")});
The code is simple and does not need to be explained. Use it to know. Haha.