JavaScript DOM content/operation steps

Source: Internet
Author: User
Tags tag name

The Document object is part of the Window object and can be accessed through the Window.document property

Usually through the JS can manipulate HTML elements, first of all to find this element;

    • By using the getElementById ("id") method//id the label has only one
    • Find an array by using the getElementsByTagName ("") method//based on the tag name
    • By using the Getelementsbyclassname ("") method//Based on classname, locate the array
    • By using the Getelementsbyname ("") method//Based on name, find the array Zhu: enclosed in parentheses

Window Object properties and Properties http://www.runoob.com/jsref/obj-window.html

Document Operation:

1, find elements get element 、、、
2, Operation content innerHTML

Non-element content properties:. InnerHTML Sets or returns the contents of the element//Example: Documentgetmentbyid ("id"). InnerHTML (content within the element is:)

Form element content properties:. value

Element link:. href page Jump form:. target~~

<script>function  changelink () {    document.getElementById (' Myanchor '). innerhtml= "Gold Baidu" ;    document.getElementById (' Myanchor '). href= "Http://www.baidu com";    document.getElementById (' Myanchor '). target= "_blank";} </script>
link and jump chestnuts

3. Operation Properties:

Set SetAttribute ("Properties", "Property values")

Get getattribute ("attribute name")

Delete RemoveAttribute ("Property name")

Chestnut

4. Function Style:

element. style. style = "";

<script type= "Text/javascript" >function on (obj) {        = ' 200px ';         = "200px";    }     </script>        >
function Style chestnut

5. Operation elements (create tags, delete tags)

Time Control:

SetInterval (): Invokes a function or evaluates an expression by the specified period (in milliseconds).

SetTimeout (): Invokes a function or evaluates an expression after the specified number of milliseconds.

JavaScript DOM content/operation steps

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.