Get value of tag <span> in DOM - Javascript jQuery

Javascript examples for jQuery:Text

Description

Get value of tag <span> in DOM

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//  w w  w.jav a2 s  .  c o m
var a = document.getElementById('my').childNodes[0].textContent.match(/[^<]+/);
console.log(a);
    });

      </script> 
 </head> 
 <body> 
  <span class="-label value x" id="my"> GENISSON.MATOS <a href="default.aspx?ac=2"> ( Out) </a> </span>  
 </body>
</html>

Related Tutorials