2 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
4 <title>Delayed remove of an element
</title>
6 <script type=
"text/javascript">
11 function timedRemove()
13 var t = setTimeout('removeElement()',
500);
14 t = setTimeout('insertElement()',
2000);
17 function removeElement()
19 var element = document.getElementById('element-to-remove');
20 elementId = element.id;
21 parentNode = element.parentNode;
22 parentNode.removeChild(element);
25 function insertElement()
27 var newElement = document.createElement('p');
28 newElement.setAttribute('id', elementId);
29 newElement.innerHTML = 'new element';
30 parentNode.appendChild(newElement);
37 <input id=
"buttonDelete" type=
"button" value=
"element will be removed in half a second"
38 onclick=
"timedRemove()"/>
40 <p id=
"element-to-remove">element
</p>