dynamic.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6. <script type="text/javascript">
  7. var next = 0;
  8. function addMore() {
  9. var box = document.createElement('DIV');
  10. box.id = 'box' + next++;
  11. box.className = 'redbox';
  12. box.style.width = '150px';
  13. box.style.height = '150px';
  14. box.style.backgroundColor = 'red';
  15. box.style.border = '1px solid black';
  16. box.style.margin = '5px';
  17. window.setTimeout(function() {
  18. document.body.appendChild(box);
  19. }, 1000);
  20. }
  21. function reveal() {
  22. var elem = document.getElementById('revealed');
  23. window.setTimeout(function() {
  24. elem.style.display = '';
  25. }, 1000);
  26. }
  27. </script>
  28. </head>
  29. <body>
  30. <input id="adder" type="button" value="Add a box!" onclick="addMore()"/>
  31. <input id="reveal" type="button" value="Reveal a new input" onclick="reveal();" />
  32. <input id="revealed" style="display:none;" />
  33. </body>
  34. </html>