How JavaScript supports W3C DOM templates

Source: Internet
Author: User

How JavaScript supports W3C DOM templates

This Document Object Model allows access to all document content and modifications, as standardized by the World Wide Web Federation (W3C. Almost all modern browsers support this mode.

Most of the traditional DOM functions in W3C DOM specifications are added with new important functions. Apart from supporting other array attributes of forms [], images [] and document objects, it defines methods to enable scripts to access and manipulate any document element, not just dedicated component-like forms and images.
Document attributes are stored in W3C DOM:

This model supports all attributes provided by traditional DOM. In addition, here is the document attribute. You can use W3C DOM to access the list:

In W3C DOM:

This model supports all methods provided by traditional DOM. In addition, here is a list of methods supported by W3C DOM:

Example:

This is very easy to manipulate using W3C DOM document elements (access and settings. You can use any method similar to getElementById, getElementsByName, or getelementsbytagname.

The following is an example of accessing the document attributes using the W3C DOM method:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

<Html>

<Head>

<Title> Document Title </title>

<Script type = "text/javascript">

<! --

Function myFunc ()

{

Var ret = document. getElementsByTagName ("title ");

Alert ("Document Title:" + ret [0]. text );

 

Var ret = document. getElementById ("heading ");

Alert (ret. innerHTML );

}

// -->

</Script>

</Head>

<Body>

<H1 id = "heading"> This is main title

<P> Click the following to see the result: </p>

 

<Form id = "form1" name = "FirstForm">

<Input type = "button" value = "Click Me" onclick = "myFunc ();"/>

<Input type = "button" value = "Cancel">

</Form>

 

<Form d = "form2" name = "SecondForm">

<Input type = "button" value = "Don't ClickMe"/>

</Form>

 

</Body>

</Html>

Note: For returned objects such as the form and content of this example, we will have to use the attributes of these objects not discussed in this tutorial to access their values.

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.