<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
div {
width:100px;
height: 100px;
background-color: pink;
}
</style>
<style>
.change{
background-color:purple;
color: #fff;
font-size: 25px;
margin-top: 100px;
}
</style>
<body>
<div class="first">文本</div>
<script>
var ele = document.querySelector('#box');
ele.style.width = '100px';
ele.style.height = '100px';
ele.style.transform = 'rotate(7deg)';
</script>
<script>
var test = document.querySelector('div');
test.onclick = function() {
this.className = 'change';
this.className = 'first change';
};
</script>
</body>
</html>
操作style属性
最新推荐文章于 2024-09-15 19:46:31 发布