JS-[IE, FF] dynamic acquisition of Node Code innerhtml Analysis

Source: Internet
Author: User

[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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.