Part 34 | JavaScript Tutorial | DOM methods | getElementById | ElementsByTagName | querySelectorAll

Publicado em: 04 Março 2023
no canal de: Trinits Technologies
65
0

DOM stands for Document Object Model.
The HTML DOM is a standard for how to get, change, add, or delete HTML elements.

Find the HTML elements:-
-------------------------
document.getElementById(id)
Find an element by element id
document.getElementsByTagName(name)
Find elements by tag name
document.getElementsByClassName(name)
Find elements by class name

document.querySelectorAll("p.intro");
Find elements based on css selectors.

Change the HTML element values:
---------------------------
element.innerHTML = new html content
Change the inner HTML of an element

element.attribute = new value
Change the attribute value of an HTML element


element.style.property = new style
Change the style of an HTML element

Adding and Deleting Elements:-
------------------------------
document.createElement(element)
Create an HTML element

const div = document.createElement('div'); // create new div element
div.textContent = 'Hello, world!'; // set the text content of the div
document.body.appendChild(div); // append the div to the document body


document.removeChild(element)
Remove an HTML element

const img = document.getElementById('myImage'); // get the image element
document.body.removeChild(img); // remove the image from the document body

document.appendChild(element)
Add an HTML element
const div = document.createElement('div'); // create new div element
div.textContent = 'Hello, world!'; // set the text content of the div
document.body.appendChild(div); // append the div to the document body

Add events using Javascript code.:-
document.getElementById(id).onclick = function(){code}


Nesta página do site você pode assistir ao vídeo on-line Part 34 | JavaScript Tutorial | DOM methods | getElementById | ElementsByTagName | querySelectorAll duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Trinits Technologies 04 Março 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 65 vezes e gostou 0 espectadores. Boa visualização!