classList的使用

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title</title>
<style>
.changebig{
font-size: 30px;
}
</style>
</head>
<body>
<div class="div1 div2" id="ID1">hello1
<div>hello2</div>
<p>pp</p>

</div>
<script>
var ele=document.getElementById('ID1');
// alert(ele.className);//div1 div2
ele.classList.add('changebig');//给div标签添加类名为changebig的属性
ele.classList.remove('changebig');//取消类名为changebig的属性
</script>

</body>
</html>
上一篇:8、【死磕 Spring】—— IoC 之解析Bean:解析 import 标签


下一篇:下拉选择框select元素的定位,报错:ElementNotInteractableException