Javascript examples for DOM HTML Element:Span
Change element from <span> to <h1> by creating a new element and swap
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w w w . j a v a2 s . c om var mySpan = document.getElementById("myId"); var myH1 = document.createElement("h1"); myH1.innerHTML = mySpan.innerHTML; mySpan.parentNode.replaceChild(myH1, mySpan); } </script> </head> <body> <span id="myId">Hello</span> </body> </html>