用js改变div2的css 实现窗口的隐藏显示
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>div的显示隐藏</title>
</head>
<style type="text/css">
.div1{
width:100px;height:100px;background:red;
}
.div2{
width:100px;height:100px;background:green;display:none
}
</style>
<body>
<div class="div1" onclick="changeCss()">点击显示div2</div>
<div class="div2" id="div2">我是div2 且3秒后消失</div>
<script type="text/javascript">
function changeCss(){
//获取div2
var div2 = decument getElementById('div2')
//div2 显示
div2.style.display = "block";
//三秒后隐藏
setTime(function(){
div2.style.display = "none";
},3000);
}
</script>
</body>
</html>