Javascript DOM programming Art

Source: Internet
Author: User

Built-in object:JavascriptThe defined object is called the built-in object! (For example, array, math, date)
Host object:Objects running in a specific environment are host objects. For example, predefined objects provided by Web browsers are called host objects. The host objects mainly include form. Image and element. You can use these objects to obtain information about forms, images, and various form elements on a given webpage.

Objects in javascript can be divided into three types:
User-Defined Object:ProgramObjects created by members.
Native object: objects built in Javascript language.
Host object: The object provided by the browser.

Node:
1. element node.
2. Text node.
3. Attribute nodes.
4. CSS

Case Sensitive
Getelementbyid () method
Example: Document. getelementbyid ("puchases ")
The id value must be enclosed in single or double quotation marks.
Note: this call will return an object, which corresponds to a unique element in the document object. The html id attribute value of that element is purchases. we can use the typeof operator for verification. typeof allows us to know whether the operand is a string, value, function, Boolean value or object.

< Script Type = " Text/JavaScript " >
Alert ( Typeof Document. getelementbyid ( " Purchases " ));
< / SCRIPT>

 

Getelementsbyidtagname () method
Note: This call returns an array of objects, each of which corresponds to an element with a given tag in the document.
Example: Document. getelementsbytagname ("Li ")
You can use for to traverse this array.

For (Far I = O; I < Document. getelementsbytagname ( " Li " ). Length; I ++ )
{
Alert (TypeofDocument. getelementsbytagname ("Li") [I]);
}

In order not to repeatedly input document. getelementsbytagname ("Li"), you can assign it to a variable.

VaR Items = Document. getelementsbytagname ( " Li " )
For ( VaR I = 0 ; I < Items. length; I ++ )
{
Alert (TypeofIttems [I]);
}

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.