Get text inside one span tag to another span tag - Javascript DOM

Javascript examples for DOM:Element textContent

Description

Get text inside one span tag to another span tag

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <div> 
         <span>40.78</span> 
      </div> 
      <span id="test"></span> 
      <script>
      var span = document.getElementsByTagName("span")[0];
      var test = document.getElementById( 'test' );
      test.textContent = span.textContent;
      console.log(test.textContent);
     /*from   w w w  . ja  v a2s  . c o  m*/
      </script>  
   </body>
</html>

Related Tutorials