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}
На этой странице сайта вы можете посмотреть видео онлайн Part 34 | JavaScript Tutorial | DOM methods | getElementById | ElementsByTagName | querySelectorAll длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Trinits Technologies 04 Март 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 65 раз и оно понравилось 0 зрителям. Приятного просмотра!