Alibabacloud.com offers a wide variety of articles about how to use document getelementbyid, easily find your how to use document getelementbyid information here online.
In the Web standard, you can use getelementbyid (), getelementsbyname (), and getelementsbytagname () to access any tag in the document.
(1) getelementbyid ():
Getelementbyid () can access a specific element in the document. As the name suggests,
In the Web standard, you can use getelementbyid (), getelementsbyname (), and getelementsbytagname () to access any tag in the document.
(1) getelementbyid ():
Getelementbyid () can access a specific element in the document. As the name suggests,
In js writing, you often need to obtain the id object. If you use getElementById directly to obtain the object, there are many codes and the old browser does not support this attribute. You can consider using the following code. For example, use _ $
Document. all is a proprietary attribute of IE 4.0 and later versions. It is a group of all objects in the current document, including not only object objects visible on the page, but also invisible objects, for example, html annotations. In the
Use your brain as a browser to execute the following code twice: IE6 and IE9:
Copy codeThe Code is as follows: function testFunc (){
Alert ('test ')
}
$ (Function (){
Var g = document. getElementById,
W = window. testFunc;
// G
Alert (typeof (g
CopyCodeThe Code is as follows: function $ (ID) {return document. getelementbyid (ID );
The previous version of the browser is no problem, if you use an old browser, you can use the following functionCopy codeThe Code is as follows: function $
JavaScript can define $ symbolic functions, which can be abbreviated or written with better compatibility.
The Code is as follows:
Function $ (id) {return document. getElementById (id );
The previous version of the browser is no problem, if
Copy codeThe Code is as follows:Function $ (id) {return document. getElementById (id );The previous version of the browser is no problem, if you use an old browser, you can use the following functionCopy codeThe Code is as follows:Function $
Document. getElementById is a public standard and supported by all mainstream browsers, document. all only supports IE, document. layers is the proprietary document of Netscape4.x. all is a proprietary attribute of IE 4.0 and later versions. It is a
In JavaScript, the document. Write () method is often used to output content from a webpage to a document.Example: The document. Write () method is used to output a piece of text to the webpage document.Document. Write ("I love learning-I like
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.