Blogger Information
Blog 47
fans 1
comment 0
visits 53270
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js事件 点击按钮显示div 三秒后自动消失
晴天
Original
3410 people have browsed it

用js改变div2的css 实现窗口的隐藏显示

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>div的显示隐藏</title>
  6. </head>
  7. <style type="text/css">
  8. .div1{
  9. width:100px;height:100px;background:red;
  10. }
  11. .div2{
  12. width:100px;height:100px;background:green;display:none
  13. }
  14. </style>
  15. <body>
  16. <div class="div1" onclick="changeCss()">点击显示div2</div>
  17. <div class="div2" id="div2">我是div2 且3秒后消失</div>
  18. <script type="text/javascript">
  19. function changeCss(){
  20. //获取div2
  21. var div2 = decument getElementById('div2')
  22. //div2 显示
  23. div2.style.display = "block";
  24. //三秒后隐藏
  25. setTime(function(){
  26. div2.style.display = "none";
  27. },3000);
  28. }
  29. </script>
  30. </body>
  31. </html>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post