JavaScript: Strip Out Tags
by MythOfEchelon
HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
html {
font: 16px "Segoe UI", "Segoe WPC", Helvetica, Arial, "Arial Unicode MS", Sans-Serif;
}
</style>
</head>
<body>
<div id="page_Wrapper">
<h1>h1</h1>
<br />
<br />
<br />
<b>b</b>
<br />
<i>i</i>
<br />
<u>u</u>
<div>div</div>
<span>span</span>
</div>
<script>
window.onload = removeTags;
function removeTags(){
var allTags = document.getElementById("page_Wrapper").childNodes;
var i = allTags.length;
while (i--){
var tag = allTags[i].nodeName.toLowerCase();
if (tag != "b" && tag != "br" && tag != "i"){
allTags[i].parentNode.removeChild(allTags[i]);
}
}
}
</script>
</body>
</html>