Source: Internet
Author: User
Tags tag name

First, get the style of the element
    1. Non-inline style;
    2. The inline style.
1.currentstyle:ie supports methods for obtaining non-inline styles; Usage: object. currentstyle. Style name; Example: Odiv.currentstyle.width;2.getcomputedstyle: Except IE6, 7, 8, Methods for obtaining non-inline styles; Usage: getComputedStyle (object, parameter). style name; The second parameter can pass any data, usually passing false or null; Example: getComputedStyle (odiv,null). Color; What is Domdom is an API (application programming Interface) for HTML and XML documents. The DOM depicts a hierarchical tree of nodes that allows developers to add, remove, and modify portions of a page. All nodes in the DOM tree can be accessed via JS, and all HTML elements (nodes) can be modified, created, or deleted. All content in the node-type HTML document is node:
    • The entire document is a document node;
    • Each HTML element is an element node;
    • text within an HTML element is a text node (a carriage return is also a text node);
    • The attribute of each HTML is the attribute node GetAttributeNode (' id ');
    • A comment is a comment node.
The NodeName property returns the name of the node:
    • The nodename of the element node is the tag name (uppercase);
    • The nodename of the attribute node is the property name;
    • The nodename of text nodes is always #text;
    • The nodename of a document node is always documents.
The NodeValue property returns the value of the node:
    • For element nodes, the NodeValue return value is undefined or null;
    • For text nodes, NodeValue returns text content;
    • For attribute nodes, NodeValue returns the value of the property;
    • For element nodes, set the value/Get value with innerHTML.
The NodeType property returns an integer that represents the type of node that is commonly used for node types: ELEMENT nodes return 1, attribute nodes return 2, Text nodes return 3, note nodes return 8, and document nodes return 9. Iv. Relationship of nodes
    • ChildNodes: All child nodes;
    • NextSibling: Next sibling node;
    • PreviousSibling: previous sibling node;
    • FirstChild: first child node;
    • LastChild: the last child node;
    • Children: All child nodes of the tag type;
    • ParentNode: Parent node.
V. Common methods for operating nodes 1. Find method: document.getElementById (');d ocument.getelementsbytagname ("); 2. Replication node: CloneNode (Boolean): Copy a node true: deep Copy, copy node and its entire subtree false: shallow copy, copy only node itself note: CloneNode () method does not copy JavaScript attributes that are added to the DOM node, such as event handlers. 3. Operation node: createelement (' tag name '): Create new Element createTextNode ("): Create text node creation method: Document.createelement (' div '); appendchild (node) : Insert a node at the end Node;insertbefore (node,targetnode): Target before inserting node Node;replacechild (NewNode, OldNode): New replace node old; RemoveChild (node): Removes a child node of the parent node; getattribute (' name '): Gets the value of the Name property on the node; GetAttributeNode (' type '): Gets the tape attribute on the node ; SetAttribute (' name ', ' value '): Sets the value of the Name property on the node to Value;removeattribute (' name '): Removes the name attribute on the node.


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.