JavaScript: Reading and setting style attributes of document elements _ javascript skills

Source: Internet
Author: User
Tags table definition
Sometimes we need to use js to set the style attributes of the document. The following describes some methods and principles for analysis. You can see that it is okay. First, let's talk about the style sheet attributes.
1. inline style is set in the element style attribute, with the highest level
2. Page Style table definition is page Level 2
3. External link style table File
JavaScript gets and sets the css attributes of document elements:
1. Get the Style attribute set in the element Style attribute,
Document. getElementById (id). style. height;
If yes, the property value is returned. If no value is returned, null is returned.
Both IE and Firefox are available, but some attribute values may return different values. For example, Firefox returns rgb, While IE returns hexadecimal numbers.
Test code:
Related Article

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.