The Processing Methods of innerhtml and value in IE, Firefox, and chrome are different.

Source: Internet
Author: User

Create a new document, input the content, and rename it ".

1:<Textarea ID= "QQ"> </Textarea>
3:// Document. getelementbyid ("QQ"). value = '000000 ';
4:Document. getelementbyid ("QQ"). Innerhtml ='Sfsdfsdfsfaf';
5:Document. getelementbyid ("QQ"). Value ='123';
6:// The innerhtml and value of the "QQ" node are displayed.
7:Alert ("Innerhtml :"+ Document. getelementbyid ("QQ"). Innerhtml +"Value :"+ Document. getelementbyid ("QQ"). Value );

1. assign values to innerhtml first, and then assign values to value

Open with IE 7 and the result is as follows:

Open it with Firefox 4.0.1 and the result is as follows:

Open chrome 10.0.648.204 with the same result as Firefox:

2.CodeComment out the fifth line in, and the results in the three browsers are the same:

3. Cancel the comments on the third line. The result is as follows:

    Conclusion: ◎ assign values to innerhtml and value to value. In IE 7, the value will overwrite the innerhtml value, but will not be overwritten in Firefox 4 and chrome 10.

    ◎ Assign values only to innerhtml and not to value. The three browsers automatically assigned the innerhtml value to the value.

    ◎ Assign values first, and then assign values to innerhtml. In Firefox 4, The innerhtml value does not overwrite the value, and the other two Browsers Do Not.

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