1. You can write various assignment statements in your work.
For example, the most common obj. style. Display = "NONE ";
If there are more than one assignment statement, obj. style will be dizzy in a row.
The following extend functions in my base. js can be used to assign values to attributes or even function handles in JSON format.CopyCodeThe Code is as follows :/**
* Extended functions
* @ Param target refers to the object to be extended.
* @ Param Params attributes and methods to be put into the target
*/
Function extend (target, Params ){
If (! Target ){
Target = {};
}
For (VAR prop in Params ){
Target [prop] = Params [prop];
}
Return target;
}
2. Because IE does not fully comply with W3C standards, its event model is different from that of other browsers.Different methods are called.
If you want to dynamically add events to the control. Using onclick = function () {} is not necessarily valid when Dom is dynamically created, and multiple handles cannot be bound. Next we will introduce a universal function that supports binding events to the entire browser.
In most cases, usecapture uses false, so it is simply written to death.Copy codeThe Code is as follows :/**
* Dynamically create event handles
* @ Param control refers to the object to be extended.
* @ Param eventname event name
* @ Param FN function handle
*/
Function addeventlistener (control, eventname, FN ){
If (window. attachevent ){
Control. attachevent ('on' + eventname, FN );
} Else {
Control. addeventlistener (eventname, FN, false );
}
}
For the sample of the above two functions, refer to otherArticleCode in