familiar with DOM (Document Object Model).
Gets | Syntax | Method |
---|---|---|
ID | #name | getElementById() |
class | .name | getElementsByClassName() |
Tag | h1,p etc. | getElementsByTagName() |
Selector (Single) | .classname, #idName | querySelector('.className'), querySelector('#idName') |
Selector (all) | .className | querySelctorAll() |
document.getElementById(elementID);
className: The className property sets or returns the class name of an element childNodes: The childNodes property returns a collection of a node's child nodes.
parentNode: The parentNode property returns the parent node of the specified node. innerText: The innerText property sets or returns the text content of the specified node. innerHTML: The innerHTML property sets or returns the HTML content of an element.
<h1 id="demo">Heading 1</h1>
console.log('demoId');
Comments
Post a Comment