JavaScript DOM objects

Source: Internet
Author: User

Introduction to DOM

1. HTML DOM: When a Web page is loaded, the browser creates a Document object model for the page

2. Dom Operation HTML

JS can change all the HTML elements in the page

JS can change all the HTML properties in the page

JS can change all CSS styles in the page

JS can respond to all the events on the page

Dom manipulating HTML

1. Change the HTML output stream: Note never use document.write () after the document is loaded. This overwrites the document

2. Searching for elements: Finding HTML elements by ID

Find HTML elements with tag names

document.getElementsByTagName ("P");//The first of the same elements

3. Change HTML content: Use attribute: InnerHTML

4. Changing HTML properties: Using attributes: Attribute

Dom manipulating CSS

1. Changing CSS through DOM objects

Syntax: document.getElementById (ID). style.property=new style

DOM EventListener

1. DOM EventListener

Methods: AddEventListener (); method is used to add a time handle to the specified element (more convenient)

Removeeventlistenner (); To remove an event handle added by a method

JavaScript DOM 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.