Native to remove js inline style

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

  1. js加上class: $dom.classList.add('some-class');
  2. js去除class: $dom.classList.remove('some-class');
  3. Js the set the line style: $ dom.style.height = '10px';
  4. js removed inline style: $ dom.style.height = '';

It is worth noting, JS remove the inline styles are assigned directly to an empty string ! ! !

Guess you like

Origin www.cnblogs.com/yangzhou33/p/11361293.html