<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.box{width: 200px;height: 200px;background: yellowgreen}
.page{color: red}
.btn{font-size: 20px;}
</style>
</head>
<body> <div class="box">这是测试</div> <script>
var box=document.getElementsByClassName("box")[0]; box.className=box.className+" "+"page";//增加类名
box.classList.add("btn");//增加类名
box.classList.remove("btn");//移除类名
box.classList.item(1);//根据索引找类名
console.log(box.className);
console.log(box.classList.item(1)) </script>
</body>
</html>

最新文章

  1. EF6 连接Oracle 迁移数据错误解决方法
  2. 使用EntityFramework6.1的DbCommandInterceptor拦截生成的SQL语句
  3. Portable Operating System Interface for uni-X
  4. XPath学习:轴(14)——总结
  5. Apps Vol53
  6. python - 回溯继承树 - 自己实现
  7. C++学习笔记-2-构造函数和析构函数
  8. shell command使用技巧
  9. 关于@font-face的一些问题
  10. 详细介绍ASP.NET页面重定向方法
  11. cooking eggs
  12. Hbulider里面template模板自用
  13. [iOS]C语言知识点系列视频
  14. WinForm 对话框、流
  15. oracle sql 树操作
  16. Mysql 的 IF 判断
  17. 【持续跟新】剑指Offer_Java实现
  18. LDOOP ADD_PRINT_TEXT多页项
  19. Asp.net+WebSocket+Emgucv实时人脸识别
  20. POI导入工具类

热门文章

  1. OdDbAttribute和OdDbAttributeDefinition是什么关系
  2. JS规则 我还有其它用途( +号操作符)例如,算术操作符(+、-、*、/等),比较操作符(&lt;、&gt;、&gt;=、&lt;=等),逻辑操作符(&amp;&amp;、||、!)
  3. 接口测试——postman
  4. 北京服务业占GDP比重达81.7%
  5. 图书-技术-SpringBoot:《Spring Boot 企业级应用开发实战》
  6. iOS之UIButton的normal和selected状态切换
  7. Python基础---序列对象
  8. springcloud(十):Hystrix工作流程分析
  9. Linux文件句柄数配置
  10. 2018-11-26-win10-uwp-获取窗口的坐标和宽度高度