Outline
Today I used to dom element set style js , encountered some problems, write it down for future reference when developing, I believe it is useful to others.
Experience
- js加上class: $dom.classList.add('some-class');
- js去除class: $dom.classList.remove('some-class');
- Js the set the line style: $ dom.style.height = '10px';
- js removed inline style: $ dom.style.height = '';
It is worth noting, JS remove the inline styles are assigned directly to an empty string ! ! !