Javascript examples for DOM HTML Element:Div
Create div and append html as its content and search added elements
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . ja v a 2 s . c om*/ var s = '@test <span class="myString">@test</span> @test2 <span class="myString">@test</span>'; var e = document.createElement("div"); e.innerHTML = s; var spans = e.getElementsByTagName("span"); while (spans.length > 0) { e.removeChild(spans[0]); } console.log(e.innerHTML); } </script> </head> <body> </body> </html>