[IE, FF] dynamic acquisition of Node Code innerhtml Analysis
Code
<Div id = "parentnode">
<Span id = "childnode"> child </span>
</Div>
<SCRIPT type = "text/JavaScript">
VaR childnode = Document. getelementbyid ("childnode"), parentnode = Document. getelementbyid ("parentnode ");
</SCRIPT>
When you add a default attribute for a subnode:
Childnode. classname = "childclass"; or: childnode. classname = new string ("childclass ");
Parentnode. innerhtml IE and FF can obtain [<SPAN class = "childclass" id = "childnode"> child </span>]
When you add a private attribute to a subnode:
Childnode. type = "childtype ";
Parentnode. innerhtml if and only if IE can obtain [<span type = "childtype" id = "childnode"> child </span>]
Childnode. type = new string ("childtype"); // object
Neither parentnode. innerhtml ie nor FF can obtain [<span id = "childnode"> child </span>]
Childnode. setattribute ("type", "childtype ");
Parentnode. innerhtml IE and FF can obtain [<SPAN class = "childclass" id = "childnode"> child </span>]
Childnode. setattribute ("type", new string ("childtype "));
Parentnode. innerhtml if only FF can obtain [<SPAN class = "childclass" id = "childnode"> child </span>]
When the private attribute is dynamically added to the element, the innerhtml is obtained. attribute assignment, no matter which data type Firefox can obtain, if the assignment type is an object, ie cannot be obtained through innerhtml.
If you use the setattribute method to assign values, Firefox can obtain either of the data types. If the value type is an object, ie cannot obtain the value.
Conclusion: innerhtml cannot change the value assignment type in the IE environment, and the attribute method cannot be changed in the Firefox environment.