JSP gets the text value and parameter attribute value of the DOM node and the node

Source: Internet
Author: User
Tags tag name

1. How to get nodes:

1) Get the node through the top layer:

document.getElementById (""); Gets the attribute value of the node by ID. Note: If you have more than one node with the same ID, only the first node is returned

Document.getelementsbyname (""); Returns an array of the same name element. Then, by judging the property to determine whether the node is required, take radio,checkbox as an example, by judging whether the check property is true;

document.getElementsByTagName (); Gets data by tag name, returns a set of nodes of the same label;

2) Get through parent node:

Obj.firstchild; The first child node of a known node, and the ability to recursively use obj.firstchild.firstchild.firstchild ....

Obj.lastchild; The last node of the known node; Obj.lastChild.lastChild.lastChild can be recursively used ....

The above two ways can alternately use obj.firstChild.lastChild.firstChild ...

Obj.childnodes: Gets the array of child nodes for the known node. Gets the desired node by looping through the index.

Parentobj.children: Gets an array of direct child nodes for a known node.

Parentobj.getelementsbytagname (): Gets an array of all child nodes of the specified type for the known node;

3) query by neighboring nodes:

Neighbournode.previoussibling: Gets the previous node of a known node; it can be used iteratively and can be used in combination with Firstchild,lastchild.

neighbournode.nextsilbling: Gets the next one of the known nodes nodes, can be used iteratively, or mixed with firstchild,lastchild.

3) Get through child nodes:

Childnode.parentnode; Gets the parent node through a known node.

Note: The document method gets: from the global find; The Document object is part of the Window object;

    

JSP gets the text value and parameter attribute value of the DOM node and 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.