JavaScript Learning Summary (i) DOM Document Object model

Source: Internet
Author: User


I. Documentation (D)


A Web page runs in a browser, and he is a document object.


Ii. Objects (O)


An "Object" is a self-contained . A variable associated with a particular object is called a property of this object, and a function called only by an object is called the method of this object.



There are three types of objects in javascript:



① user-defined objects: do not know



② built-in objects (native object): JavaScript exists from the beginning. Columns such as array,math,date (JavaScript syntax is case-sensitive)



③ Host object: The object provided by the browser. columns, such as window objects, do not use this object as much as possible.


Iii. Model (M)


In the DOM, the model models represent the representation of a class of things, the browser provides a model of the Web page, JavaScript reads the model, obtains information, and operates the DOM.


<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD"><HTMLxmlns= "http://www.w3.org/1999/xhtml"Lang= "en"> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title></title> </Head> <Body> <H1>Dom</H1> <ul> <Li>1</Li> <Li>2</Li> </ul> </Body></HTML>


The HTML represents the entire document under the,

Four, Dom object gets the element node method 1.getElementById


A function specific to the Document object. document.getElementById (ID), ID corresponds to the ID value of the node element, denoted by the value of ID or the value of ID . The Change method returns an object


2.getElementsByTagName


getElementsByTagName is similar to getElementById, whose parameter is the name of the tag, and GCA wants to get the object labeled Li, which is document.getelementsbytagname ("Li"). The return type is an object array. Gets how many element nodes of a document can be used alert (document.getelementbytagname ("*"). Length). * is a wildcard character, representing all element nodes.


3.getElementByClassName


Getelementbyclassname is a new method for HTML5 that accesses elements through the type in the class attribute. Getelementbyclassname (Class) is similar to getElementsByTagName, and the return value is also an array with the same elements.









JavaScript Learning Summary (i) DOM Document Object model


Related Article

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.