Dom operation style sheet

Source: Internet
Author: User

1. Operate style attributes

1.1 attributes of a style object

Document. getelementbyid ("BBB"). style. backgroundcolor = "red ";

// The Inline style is accessed or obtained by the attribute value of the style.

1.2 use the style object method // because IE does not support it, it is better to use the first method.

Getpropertyvalue (propertyname); // use the style in the CSS attribute: Background-color

Getpropertypriority ();

Item (INDEX );

Removeproperty (propertyname );

2. Operate the external style table. Because the style of all elements with this class will be changed once changed, we recommend that you use the style attribute of this element to change the style of an element.

2.1 obtain the CSS style table var ocssrules = document.stylesheet1_02.16.css rules | document. stylesheet [0]. Rules // rules set for IE

2.2 access a style ocssrules [0]. style. backgroundcolor

3. Check that the final style is read-only and cannot be changed. If you want to change the attribute of the style

3.1 Definition: The style displayed on the browser is overwritten due to the relationship of priority, and the display method is displayed on the browser.

3.2 ie document. getelementbyid ('dd'). currentstyle. backgroundcolor // the same as normal style

3.3dom document. defaultview. getcomputedstyle (odiv, null). backgroundcolor

Dom operation style sheet

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.