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]);
}