title: jquery - Use split to split only text?
body: <p>My code splits the text and place a html code after a certain number of words. It's working, the problem is that the split function not only splits text, but also splits HTML. How can I configure it to split text only? Let's say I have an article and I need a banner to appear in the middle of the article, if I don't take care, I'll split some div or something like that.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
   jQuery(function($) {
  
  
  var wordList = $(".newsitem_text").html().split(' ');
  var newHtml = '';
  
  $.each(wordList, function(index, word){
    newHtml += ' ' + word;
    if (index == 10) {
      newHtml += 'Some HTML goes here'     
    }        
  })
  ;
  
  $(".newsitem_text").html(newHtml);
  
  });
  
  &lt;/script&gt;
  </code></pre>