JS Windows.document Object

Source: Internet
Author: User
Tags tag name

Quad selector: class, ID, name, label

To get an object from a selector:

...................................  ClassName ("); --Class Selector

...............................  Name ("); --Name Selector

................................  TagName ("); --Tag Selector (that is, Div.) Tag name such as input)

Gets the element into the variable (except for the ID, the other gets the array, the index value should be used)

var A=document.getelementbyid ("Element id"); "The type has only one value, and the operation uses a. Event directly"

var a=documenr.getelementbyclassname ("Class name"); "The type is an array that can use a for loop for a single element operation within a group: A[i]. Event"

Three events

1. Click events [onclick]

A.onclick=function () {}

2. Mouse move-in event [onmouseover]

A.onmouseover=function () {}

3. Mouse out event [onmouseout]

A.onmouseout=function () {}

Control the style of the marker

1. Element tag. style. style = "value";

Change the background color of the ID ' AA ' to Black: aa.style.backgroundcolor= "red";

Here the Background-color becomes Backgroungcolor, is the JS in all the "-" attributes are removed, and the first letter behind it becomes uppercase.

2. The first element is a[0] When the array data is traversed for a loop.

To mark style operations on an element in a loop, the style of theJS change changes all styles (inline style has the highest precedence)

JS Windows.document Object

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.