Get text from element - Javascript jQuery

Javascript examples for jQuery:Text

Description

Get text from element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
   </head> 
   <body> 
      <span class="alerts">1</span> 
      <script>
    var notifications = $('.alerts').text();
    document.title = '(' + notifications + ') ' + document.title;
  
      </script>  
   </body>//from   ww  w. ja  v  a  2s.c  om
</html>

Related Tutorials