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}
Auf dieser Seite können Sie das Online-Video Part 34 | JavaScript Tutorial | DOM methods | getElementById | ElementsByTagName | querySelectorAll mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Trinits Technologies 04 März 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 65 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!