wrap text nested in an anchor tag, within a span - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

wrap text nested in an anchor tag, within a span

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <div class="print"> 
         <p>
            <a href="/">Printable Format</a>
         </p> 
      </div> 
      <script type="text/javascript">
var dtag = document.getElementsByClassName('print');

var atag = dtag[0].getElementsByTagName('a')[0];

atag.innerHTML = '<span>' + atag.innerHTML+ '</span>';

      </script>  
   </body>// ww  w.ja v  a  2s.  c o  m
</html>

Related Tutorials