JavaScript learning notes, javascript
The most common object in Javascript is the document object.
Document Object:
Each html document loaded into the browser will become a document Object. We can use the document object to access elements in HTML.
1. document. getElementById ()
Get the corresponding value through id
1. Text Box
<Html>
To obtain the value of the drop-down list box
2. drop-down box
<Html>
Ii. document. getElementsByName
This method is similar to getElementById, but getelementById returns an object, while getElementsByName returns a List, this method is usually used in text boxes or checkboxes with the same name. (For details about the checkbox function, see the full selection function in the previous article list)
Iii. document. getElementByTagName
GetElementsByTagName obtains a set under a specified tag, and is not included in the Set range because of the location where the tag is placed (for example, to write another form, there are also elements represented by the input tag. It is still included in the elements set and can be found through getElementsByTagName)
The combination of the above three methods is a common step for creating web pages. Therefore, you must understand the above knowledge.
4. There are also some methods and object sets for document.
Document. write: write HTML expressions or Javascript code to the document.
Sometimes the document. write () method is used when we dynamically create html tags.
Document. forms []: return all form references in the document. If we want to obtain the value of the text box in a form, we can do this:
V. About innerText and innerHTML
Both innerText and innerHTML can add relevant information to the TAG body. For example, we define a <span id = "feedback"> </span>, the returned information can be placed in the <span> by dynamic loading. here we can use innerText or innerHTML. When I was working on the project today, I found that Firefox does not support the innerText attribute. The solution is to replace innerText with innerHTML.
(For reprinted articles on this site, please indicate the author and Source
Coder
Extraordinary
. Do not use it for any commercial purposes)
Javascript Study Notes
Baidu
Who has javascript study notes? Send me one.
Download the learning Manual Online! Baidu search: javascript manual download