Last active
January 17, 2017 04:10
-
-
Save hackjutsu/f6c8820fe515863d726c0a00b8882f12 to your computer and use it in GitHub Desktop.
Method to clear nodes inside a html element with specific id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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