Expand|Select|Wrap|Line Numbers
- <script type="text/javascript" language="javascript">
- function main(){
- var main = document.getElementById("main");
- var bld = document.createElement("h1");
- bld.setAttribute("id","bigText");
- bld.appendChild(document.createTextNode("Greg is Great"));
- main.appendChild(bld);
- var input = document.getElementById("mybutton");
- input.parentNode.removeChild(input);
- var newbutton= document.createElement("input");
- newbutton.setAttribute("type","button");
- newbutton.setAttribute("value","Remove Text");
- newbutton.setAttribute("onclick","remove()");
- newbutton.setAttribute("id","mybutton");
- main.appendChild(newbutton);
- }
- function remove(){
- var bigText = document.getElementById("bigText");
- bigText.parentNode.removeChild(bigText);
- var input = document.getElementById("mybutton");
- input.parentNode.removeChild(input);
- var newbutton2= document.createElement("input");
- newbutton2.setAttribute("type","button");
- newbutton2.setAttribute("value","Click Me");
- newbutton2.setAttribute("onclick","main()");
- newbutton2.setAttribute("id","mybutton");
- var main = document.getElementById("main");
- main.appendChild(newbutton2);
- }
- </script>
- <title></title>
- </head>
- <body>
- <div id='main'></div>
- <input id='mybutton' type='button' onClick='main()' value="Click Me"/>
- <a onClick="javascript:objWin=window.open('','objWin','width=600,height=450,scrollbars=yes,resizable=yes');objDoc=objWin.document;objDoc.open('text/plain');objDoc.write(document.documentElement.outerHTML);objDoc.close();">View current DOM</a>
- </body>
- </html>
Greg