Код: Выделить всё
Click Me
Код: Выделить всё
const btn = document.querySelector('#btn');
btn.style['background-color'] = 'red';
Код: Выделить всё
btn.addEventListener('click', () => {
console.log(`This button is in ${btn.style['background-color']}`)
});
Код: Выделить всё
{
... ,
"background-color": "red",
...
}
Код: Выделить всё
btn.addEventListener('click', () => console.dir(btn.style));

Подробнее здесь: https://stackoverflow.com/questions/709 ... look-wierd
Мобильная версия