An example of a JavaScript operation element locating element. It is a javascript instance.

Source: Internet
Author: User

An example of a JavaScript operation element locating element. It is a javascript instance.

It is a good choice to use js to operate element locating elements. The following is an example. If you need it, you can check it out.

<! DOCTYPE html> 

Positioning element in javascript

Supplement: lz, please add Baidu hi or qq25846111. Let's discuss it in detail.

Does "[html] [body] [table] [tbody]" mean
<Html>
<Body>
<Table>
<Tbody> what is the form?

In this case, you can search at the first level.
// Obtain the list of all body elements (only one will be available here)
MyDocumentElements = document. getElementsByTagName ("body ");
// The body element we need is the first element in the list.
MyBody = myDocumentElements. item (0 );
// Now, let's get all the table elements in the child element of the body
MyPElements = myBody. getElementsByTagName ("table ");
// Here, if you need to find the specified table, you can use a circular statement to find it from the item.
MyTable = myPElements. item (0 );
// Repeat the above process to obtain the tbody
MyTbody = myTable .. getElementsByTagName ("tbody"). item (0 );

Of course there are other methods. lz can take a look at this link.
2.16.mozilla.org/..86html

If you have any questions about dom programming, please send a message.

In JavaScript, how does one find the child element nodes of an element?

Function get_nextSibling (n)
{
Y = n. nextSibling;
While (y. nodeType! = 1)
{
Y = y. nextSibling;
}
Return y;
}

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.