JavaScript action on the contents, properties, styles of a Document object

Source: Internet
Author: User

I. Contents of operation

1.innerHTML used to set or get object initiation and content within the hormone tag ( identify html tags )

2.innerText used to set or get object initiation and content within the hormone tag (IE)

Textcontent used to set or get object initiation and content within the hormone tag (FF)

3.outerHTML is used to set or get content within the initiation and hormone tags including this object ( identify html tags )

Outertext is used to set or get the contents of the starting and hormone tags including this object

Second, Operation Properties

1. Direct Operation

Object . Properties

Object . Properties = value ( set, GET, add Property ( property value ))

2.

GetAttribute (" property ") Gets the value of the given property

SetAttribute (" Property ", " value ") setting or adding Properties

Three, the Operation style

1. Inline style

Object . style. Properties

Object . style. Properties = value ( set, GET, add Property )

****************************************************

If the attribute is "-" linked, the "-" is removed and the first letter of the following word is capitalized

****************************************************

2.css Cascading Style

1> changing Styles by ID

2> changing Styles with className ( for batch changes )

3> change or get or set the value of a property

document.stylesheets[ subscript ].rules[ subscript ].style. Properties

document.stylesheets[ subscript ].rules[ subscript ].style. Properties = value

Document.stylesheets A collection of style sheets

Document.stylesheets[0].rules List of style rules

Document.stylesheets[0].rules.style collection of style rules

document.stylesheets[ subscript ].rules[ subscript ].style. Properties

Applicable to IE

**************************************************************

document.stylesheets[ subscript ].cssrules[ subscript ].style. Properties

document.stylesheets[ subscript ].cssrules[ subscript ].style. Properties = value

Suitable for FF

***************************************************************

3. Inline style and CSS cascading style common way

object . Currentstyle. Properties IE used to get the actual style properties

getComputedStyle ( object , null) FF to get the actual style properties

*******************************

Can only get cannot set

*******************************


This article is from the "Mr.zhu-Technology Exchange" blog, please be sure to keep this source http://bjishu.blog.51cto.com/7481301/1671810

JavaScript action on the contents, properties, styles of a Document object

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.