I wish to clear text that has been outputted by javascript to an HTML element such as the body. The text is outputted using the appendChild() method. I want to be able to clear any text that has been added that way.
I've provided some sample code of what I want to do below:
Expand|Select|Wrap|Line Numbers
- <head>
- <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
- <title></title>
- <script type="text/javascript">
- function outputLine()
- {
- var li = document.createElement('LI');
- li.appendChild(document.createTextNode("Hello!"));
- document.getElementById('updateTarget').appendChild(li);
- }
- function clearBody()
- {
- //??? document.getElementById('updateTarget').???
- }
- </script>
- </head>
- <body id='updateTarget' onLoad='outputLine()'>
- <form name=select onsubmit='clearBody()'>
- <input type=submit value="Clear Me">
- </form>
- </body>