Home >Web Front-end >JS Tutorial >Detailed explanation of HTMLDOM operations in javascript_javascript skills

Detailed explanation of HTMLDOM operations in javascript_javascript skills

PHP中文网
PHP中文网Original
2017-06-07 14:24:491607browse

1. Definition: htmlDOM is an object-oriented tree model, which contains all elements in html; all elements contained in dom can be found through html.

2. Function:

1. Find html elements

1) Find elements by id (document.getElementById();)



var x=document.getElementById("d");

2) Find elements by tag name


var x=document.getElementById("m");

var y=x.getElementByTagName("p");

3) Find elements by class name

3. Change HTML

1) Change html content

2) Change html attributes

3) Change html style

4. HTMLDOM events

1) React to events

2) HTML event attributes

3) Use htmlDOM to assign events

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn