1, the DHTML
Dynamic HTML is not a new language or a new technology, but a general term for integrating existing technologies to enable web pages to maintain Dynamic effects even offline.
2, dom
Document Object Model
The Document Object Model is dedicated to manipulating documents (HTML and CSS)
3, the dom tree
DOM treats an HTML document as an inverted tree structure
In AN HTML document, all elements, attributes, text, comments, and so on are treated as a DOM node /DOM object /DOM element
4, important concept **
- The root is actually the Document object
- In JS, what we don’t need to create is automatically created by the browser’s JS interpreter, and a page only has a Document
- What it does: You can find any of the following DOM elements through the root and manipulate them
5. Get elements
- Obtained by using HTML features
// Obtain by id
const ele = document.getElementById("Id value")
// By class name
const ele = document/parent.getElementsByClassName("Label name");
// By the tag name
const ele = document/parent.getElementsByTagName("Label name");
// note that ---- could not find an empty set to return, and the return class array set was found
// add a selector for h5
const ele = document.querySelector("Selector");
const eles = document.querySelectorAll("Selector");
Copy the code
-
Search through relationships
If you want to use it, you need to find at least one person to use it
- Parent element: xx.parentNode; // Single element
- Child element: xx. Children; / / collection
- First son: xx. FirstElementChild; // Single element
- Last son: xx. LastElementChild; // Single element
- Before a brother: xx. PreviousElementSibling; // Single element
- Next sibling: xx.nextelementSibling; // Single element
Operation element *
-
The content of the element: what is in the tag
-
innerHTML
-
innerText
Summary: These two operations are almost similar, but only innerHTML can recognize a tag. InnerText can only manipulate plain text — only double tags are available
-
The value attribute
Setup and fetch content prepared specifically for single-label INPUe
-
-
Element attributes:
<div class='xx' name = 'xx' width = 'xx' zidingyi = 'xx' alt src></div> Copy the code
-
Gets the attribute value of the element
elem.getAttribute("Attribute name"); Copy the code
-
Sets the attribute value of the element
elem.setAttribute("Attribute name"."Attribute value"); Copy the code
Simplified operations on elements: — This operation cannot operate on custom attributes
-
To obtain
Elem. The property nameCopy the code
-
Set up the
Elem. Attribute name ='Attribute value' Copy the code
\
-