Created
February 5, 2015 03:07
-
-
Save leaysgur/6cfbd576d165c799747a to your computer and use it in GitHub Desktop.
removeAllElmExceptOne
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
var parentNode = document.body, | |
childNodes = parentNode.childNodes, | |
node; | |
while (1) { | |
// 1つを残して全部消す | |
if (childNodes.length === 1) { | |
break; | |
} | |
// 基本は先頭 | |
node = childNodes[0]; | |
// 残したいやつが見つかったら一つずらす | |
if ('id' in node && node.id === 'NOKOSU_ELM_ID') { | |
node = childNodes[1]; | |
} | |
parentNode.removeChild(node); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment