nxl0908

1.添加类名:

document.getElementById("myDiv").classList.add(\'mystyle\');

2.删除类名:

document.getElementById("myDiv").classList.remove(\'mystyle\');

3.检查是否含有某个css类:

myDiv.classList.contains(\'myCssClass\');
//return true  or flase;

注意:类名直接写,不可面“.”;

   如若同时添加多个类名,并列写,用逗号分隔。

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案