【JS】Intermediate1:The DOM

1.DOM(The Document Object Model)

A way to manipulate the structure and style of an HTML page.

It represents the internals of the page as the browser sees it, and allows the developer to alter it with JavaScript.

 

2.HTML is an XML-like structure

To access the DOM from JavaScript, the document object is used.

 

3.Getting an element

1)By ID

2)By Tag Name

 document.getElementByTagName("a")

Returns a NodeList=an array of the DOM Elements

3)By Class Name

document.getElementByClassName

as TagName

4)By CSS Seclector

document.querySelector('#header'); =ID~~~

document.querySelectorAll(.btn);

 

你可能感兴趣的:(media)