Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
The article uses a sample application to demonstrate DOM methods and properties and how to attach handlers to DOM events.
Listing 1. HTML Code
<body> <p id= "PARAGRAPH1" > <span>this is some text</span> <a href= "/index.html" Click here ">click here</a> <p></body>
From the DOM perspective, the P tag in the above example is represented by the DOM Element interface. It is the parent tag of the span label and a label. The span label and a label are sibling tags.
Suppose you want to get the href attribute of the code locator point in Listing 1. An easy way to access an element in the DOM is to use the getElementById method. The following code string shows part of a document interface definition that contains a getElementById signature written with an interface Definition language (IDL): Element getElementById (in Domstring elementid).
Given an element, to get the value of the href attribute, you can use the GetAttribute method to pass the property name as a parameter (in this case, href). The IDL definition section containing the GetAttribute method is: Domstring getattribute (in Domstring name).
In this example, you can implement the above interface like this: var ahref = Aelement.getattribute ("href"); "Index.html".
Exploring DOM Scripting: sample Applications
This section explores some of the features of DOM scripting. The Sticky Notes sample application is an interactive Web page that allows users to add "Sticky" comments without reloading the page. Figure 1 shows the page.
Figure 1. Sticky Notes Application Front-End
The HTML code for the page shown in Figure 1 is shown in Listing 2. In Listing 2 the head tag is a reference to CSS and JS files. In the Body tab you can already see the structure of the annotations in the page: the textarea tag and the anchor point that triggers the new annotation creation.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.