Join text from a list of tag by name - Javascript jQuery

Javascript examples for jQuery:Text

Description

Join text from a list of tag by name

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">
    $(function(){//  w  w  w. j  a va  2 s. co m
console.log($('h3').map(function(){  return $(this).text(); }).get().join("\n"))
    });

      </script> 
   </head> 
   <body> 
      <h3>First</h3> 
      <h3>Second</h3> 
      <h3>Third</h3>  
   </body>
</html>

Related Tutorials