JavaScript Basic Learning 4

Source: Internet
Author: User

DOM Object (Document Object Model )

First, the core DOM

1. Core Dom actions on label Properties (attribute) (a) check (b) delete (c))

A. The label object of the operation. SetAttribute (property name, property value): Set the properties of a label

B. The label object of the operation. GetAttribute (property name): Get Tag Properties

C. The label object of the operation. RemoveAttribute (property name) Delete Label property

2. Core DOM action on tags

Create a label

Syntax:

Document.createelement (" label name ")

such as 1:var tab_obj=document.createelement ("table")

Append tag

The Parent object . AppendChild ( the Label object to append ), appends the label object to the end of the parent object

such as 2:document.body.appendchlid ("Tab_obj");(combined as 1)

The Parent object . InsertBefore (the label object to append , before which to append), the label object is appended to the front

Remove tags

Parent Object . RemoveChild (the label object to delete ), appends the label object to the end of the parent object


Two. HTML DOM

Method:

document.getElementById (attribute value of ID)

role: by ID property value to get the Label object    


document.getElementsByTagName ("label name")

The parent object. getElementsByTagName ("label name")

role: Get objects by tag name

Note: A collection of arrays is returned here  need to use subscript for access even if you get only one label It is also a collection of arrays


Document.getelementsbyname ( property value of name)

Description: Through the tags in the Name property value to get the element

Note: This returns an array set Hopewell need to use subscript for access Even if it gets to only one label it's also an array collection


HTML DOM actions on label Properties

Increase: the Label object to manipulate . Property name = "Value"

Delete: the Label object to manipulate . Property name = ""

Change: the Label object to manipulate . Property name = "Re-assignment"

Check: the Label object to manipulate . Property name

However, the above actions on the label properties are does not contain the class   operation of the property If you want to work with the class attribute inside the tag, you must change the class to ClassName

Format:

The label object to manipulate. ClassName

Third , CSS DOM

Format:

Assignment: To manipulate the label object. Style.css Style property = "CSS property value"

Value: The label object to manipulate. STYLE.CSS Style properties

JavaScript Basic Learning 4

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.