Sep 4, 2024
div
element can have an id
attribute.id
shows up in the element’s details).getAttribute
method.let div = document.querySelector('div');
console.log(div.getAttribute('id'));
setAttribute
method.div.setAttribute('id', 'newId');
element.style.propertyName
div.style.backgroundColor = 'blue';
document.createElement
.let newButton = document.createElement('button');
newButton.innerText = "Click Me";
parentElement.append(childElement)
let div = document.querySelector('div');
div.append(newButton);
remove
method.let paragraph = document.querySelector('p');
paragraph.remove();
classList.add('className')
to add a new class.