JavaScript で CSS を操作する
const target1 = document.querySelector('#example-id'); const target2 = document.querySelectorAll('.example-class'); target1.style.setProperty('color', '#00f'); target1.style.setProperty('position', 'relative'); target1.style.setProperty('top', '3px'); target2.forEach(function (element) { element.style.setProperty('color', '#f00'); element.style.setProperty('font-weight', 'bold', 'important'); });