CPSC415A
Web Programming

Day 7 Notes

Modifying Elements

Attributes

var theDiv = document.getElementById('theDiv');
console.log(theDiv.getAttribute('class'));
theDiv.setAttribute('class', 'redDiv');

CSS

var theDiv = document.getElementById('redDiv');
console.log(theDiv.style.backgroundColor));
theDiv.style.backgroundColor = 'blue';