test_dynamic.html (1126B)
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 let next = 0; 8 9 function addMore() { 10 let box = document.createElement('DIV'); 11 box.id = 'box' + next++; 12 box.className = 'redbox'; 13 box.style.width = '150px'; 14 box.style.height = '150px'; 15 box.style.backgroundColor = 'red'; 16 box.style.border = '1px solid black'; 17 box.style.margin = '5px'; 18 window.setTimeout(function() { 19 document.body.appendChild(box); 20 }, 1000); 21 } 22 23 function reveal() { 24 let elem = document.getElementById('revealed'); 25 window.setTimeout(function() { 26 elem.style.display = ''; 27 }, 1000); 28 } 29 </script> 30 </head> 31 <body> 32 <input id="adder" type="button" value="Add a box!" onclick="addMore()"/> 33 34 <input id="reveal" type="button" value="Reveal a new input" onclick="reveal();" /> 35 36 <input id="revealed" style="display:none;" /> 37 </body> 38 </html>