Skip to content

Instantly share code, notes, and snippets.

@hackjutsu
Last active January 17, 2017 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackjutsu/f6c8820fe515863d726c0a00b8882f12 to your computer and use it in GitHub Desktop.
Save hackjutsu/f6c8820fe515863d726c0a00b8882f12 to your computer and use it in GitHub Desktop.
Method to clear nodes inside a html element with specific id
// Clear all the nodes inside the element with id 'main-area'
function clearView() {
var mainArea = document.getElementById('main-area');
var firstChild = mainArea.firstChild;
while (firstChild) {
mainArea.removeChild(firstChild);
firstChild = mainArea.firstChild;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment