Home  >  Article  >  Web Front-end  >  When to use document and document.all_Basic knowledge

When to use document and document.all_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:26:031011browse

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute ]

If with a The name attribute is set in the corresponding HTML tag of the form object, image object, and applet object. Its value will be used as the attribute name of the document object to refer to the corresponding object, but other objects cannot.
In addition, if input is used as a sub-element of form, it is wrong to directly use inputName or document.inputName to reference this object. You must use formName.inputName to reference, otherwise you can use inputName to reference.
In addition, you should I noticed that many commonly used elements do not have names.
If you want to reference an element with an id, you can only use Id or document.getElementById, document.all.id to reference it.
But for elements like this, so Like ...
can be used
linkid.href ;
linkname.href;
document.all.linkid.href;
document.all.linkname.href;
document.getElementById("linkid").href;
document.getElementsByName ("linkname")[0].href to quote

all is a collection that contains a collection of all html objects. Write a program that can access all objects. Like this:

Be careful to put the program after .
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn