JavaScript learning notes, javascript

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.