title: How to create an automatically word wrap each 40 Characters with JavaScript / JQuery
body: <p>Is it possible to create an automatically word wrap every 40 insert characters with java script? I have programmed a jQuery / javascript solution, which used the keyUp event of a textfield:</p>
  
  <pre><code>jQuery(textInputfield).keyup(function(event) {      
      var text = jQuery(textInputfield).val();            
      if(text.length == 40){
          text = text + '&lt;br /&gt;';
      }    
      var textOutput = jQuery(textOutputField);
      textOutput.empty();
      textOutput.append(text);    
  });
  </code></pre>
  
  <p>I need a more flexible solution for this code: </p>
  
  <pre><code>if(text.length == 40){
     text = text + '&lt;br /&gt;';
  }
  </code></pre>
  
  <p>How can i solve this problem?</p>