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 $
Web
Standard
Getelementbyid (), getelementsbyname (), and getelementsbytagname ()
Access
Billing NENT
Any tag in:
1. getelementbyid ("ID ")
Getelementbyid ()
Accessible
Billing NENT
A specific element in
ID
So you can only
The getElementById () method of the html DOM document Object, domgetelementbyid
The getElementById () method returns a reference to the first object with the specified ID.
Syntax:
document.getElementById(id)
The html dom defines multiple methods for
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
Can getElementById be used in any browser? Q: I know that getElementById can be used in IE, but I don't know if it can be used in other browsing scenarios, such as Firebox, Opera, netscape
Answer:
GetElementById is a standard method
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 $
Getelementbyid getelementsbyname getelementsbytagnameKnowledge needs to be updated and new, and those you have read will also be forgotten. You need to consolidate it. ^_^In the Web standard, you can use getelementbyid (), getelementsbyname (), and
1.document.getelementbyid ("") gets an object, with alert showing an "object" instead of a specific value, which has the value and length property, plus ". Value" that gets the exact value.
A. Grammar:
Oelement = document. getElementById
JS getElementById Example Tutorial
In doing Web page is getElementById will often use one, it can get a specific ID window content or change the contents of the container below let's take a look at the getElementById instance.
Add or delete
getElementById () and getElementsByTagName () one is the ID and the other is name what is the difference between them, getElementById () only for HTML operations and not the XML file processing, But getElementsByTagName is OK. Let's take a look at
as the core selector of Dom, There is a bug in IE6, which is so embarrassing. This bug will return the first element whose ID or name is equal to the input ID.
ie getelementbyid bug by situ zhengmei This is the wrong element
I have never noticed that $ ("# air") in jquery is the same thing as document. getelementbyid ("Air"). It refers to the same thing. Write a canvasProgramThe two are different.
Directly use alert () to show what the two methods actually
Definition and usageThe getElementById () method returns a reference to the first object that owns the specified ID.Grammardocument.getElementById (ID)DescriptionThe HTML DOM defines a variety of methods for finding elements, with the exception of
Document. getElementById details ① document. getElementById sometimes misses the name, which is said to be a BUG in IE;
Http://community.csdn.net/Expert/topic/4223/4223888.xml? Temp =. 1947443.
The page contains
Program code
One is name =
Definition and usageThe getElementById () method returns a reference to the first object that owns the specified ID.Grammardocument.getElementById (ID)DescriptionThe HTML DOM defines a variety of methods for finding elements, with the exception of
Document. all is the private Dom of IE, not the W3C standard DOM, so Firefox does not support document. all, while document. getelementbyid is the W3C standard DOM, which is supported by various browsers. If document. All is used on the website, a
Modify the paging class a few days ago. to jump to a specified page, you can directly enter the page number and click the button to jump to the specified page number!
When you look at this requirement, you can think of using get to pass the value,
I know that getelementbyid can be used in IE, but I don't know if it can be used in other browsing scenarios, such as firebox, opera, and Netscape.
Answer:Getelementbyid is a standard methodTheoretically, all versions that support W3C standards
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
When writing JavaScript, we will often use the document. getelementbyid () method. This long string is easy to write errors, and getelementbyid is case sensitive.
Prototype. one method advocated in JS is to use $ () for short. With the following
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.