put the next word onto a new line If a word as a space - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:jQuery Method Example

Description

put the next word onto a new line If a word as a space

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.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from w  w  w  .j  av a2  s.  co m*/
$(".hero_text").html(function(index, text) {
        return text.replace(' ', '<br>');
});
    });

      </script> 
 </head> 
 <body> 
  <div class="hero_text">
    Screen Shot 
  </div>  
 </body>
</html>

Related Tutorials