DOM Document Object Model

Source: Internet
Author: User

The DOM is a document object that encapsulates the entire page into an object. A page is made up of a number of nodes, including elements, attributes, and text. There are three ways to get page elements.

First: getElementById, with the ID value to get all the properties of the entire label.

Second: getElementsByTagName, through the tag name value to get all the properties of the entire tag, it gets the elements will be in an array, you want to take the time, to use the method of the array to take.

Third: Getelementsbyclassname, through the class name to get all the properties of the entire tag, it gets the element will exist as an array, you have to take, to use the method of the array, but he shows in the array and the second kind of a bit different, it is a tag name with a class name as an array value , this compatibility is too strong, generally rarely used.

Event: A specific interaction moment that occurs in a document or browser window, with three elements: event source, event name, event handler. There are two types of registration events, inline, and in-line. On is a registered event.

The first type of inline:

The second type is inline:

To block A's jump we can use return false.

There are two APIs for getting page text: InnerText, InnerHTML.

1. Use innertext and innerHTML to get the content between page elements

2. The difference is that innertext only gets the text information, and innerHTML will also get the label between the tags, and it is output as is.

InnerText is not supported in the early Firefox browsers, the early Firefox browser only supports Textcontent, and the new version of Firefox supports both.

When the innertext is set, it is output as is,

Because innertext will escape the greater-than sign in the program.

And innerHTML will render the label inside as a normal HTML tag.

DOM Document Object Model

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.