JavaScript statements
JavaScript statement sends a command to the browser. The purpose of a statement is to tell the browser what to do.
document.getElementById uses
Syntax: oElement = document .getElementById (sID)
Parameters: sID--required options. String.
Return value: oElemen--Object (Element).
Description: Get the object based on the specified id attribute value. Returns a reference to the first object whose id attribute value is equal to sID. If the corresponding object is a group of objects, the first object in the group is returned. If there is no matching object, return null .
Note: document.getElementById(" ") gets an object. Use alert to display "object" instead of a specific value. It has attributes such as value and length. Add .value to get is the specific value!
Details:
① document.getElementById sometimes captures name and lets go of id. It is said to be a BUG of IE
② GetElementbyId in javascript is used
in the web page The element must have an id attribute before it can be obtained through this method, such as
③There are two main ways to obtain html tags, one is Through the ID value, one is through the name attribute (the name attribute is mainly used for the input tag in the form.)
Note:
document.getElementById(" " ) What you get is an object. Use alert to display the
"object" instead of a specific value. It has attributes such as value and length. Add .value to get the
It’s a specific value!
php中文网(php.cn)
Semicolon ;
Semicolon is used to separate JavaScript statements.
Usually we add a semicolon at the end of each executable statement.
Another use of semicolons is to write multiple statements on one line.
a = 5;
b = 6;
c = a + b;
JavaScript Code
JavaScript 代码是 JavaScript 语句的序列。 浏览器按照编写顺序依次执行每条语句。 本例向网页输出一个标题和两个段落:php中文网(php.cn) 一句问候
一段话
JavaScript Code Blocks
JavaScript can be combined in batches.
A code block starts with a left curly brace and ends with a right curly brace.
The function of a code block is to execute a sequence of statements together.
This example outputs a title and two paragraphs to the web page:
php中文网(php.cn) 替代
覆盖
JavaScript statement identifier
JavaScript statements usually start with a statement The identifier starts with and executes the statement.
Statement identifiers are reserved keywords and cannot be used as variable names.
The following table lists JavaScript statement identifiers (keywords):