<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<style type="text/css">
.add{
width: 90px;
height: 90px;
background-color: red;
}
</style>
</head>
<body>
<button type='button' id='btn'>点击我谢谢</button>
<div id="demo">
</div>
<script type="text/javascript">
var btn = document.getElementById('btn');
var div = document.getElementById('demo');
btn.onclick = function(){
div.className = 'add'; //className是添加这类的关键
}
</script>
</body>
</html>
点击前无样式
点击后出现红色样式