title: JavaScript - How to insert HTML codes in the middle of the content
body: <p>I want to find the mid point of the content and insert a block of HTML codes after the <code>&lt;br&gt;</code> tag or <code>&lt;/p&gt;</code> tag so the sentence doesn't get split.</p>
  
  <p>I can find the middle point of the content, but I am not sure how to find the closest <code>&lt;br&gt;</code> tag or <code>&lt;/p&gt;</code> tag and insert HTML code.</p>
  
  <p>Here is the code that I have so far. <strong>JS Fiddle</strong> (<a href="http://jsfiddle.net/sunflowersh/BHHFZ/" rel="nofollow">http://jsfiddle.net/sunflowersh/BHHFZ/</a>) </p>
  
  <p><strong>jQuery</strong></p>
  
  <pre><code>$(document).ready(function(){
  var content = $(".content");
  
  var contentLength = $('.content').text().length;
  
  var midLength = parseInt(contentLength / 2);
  
  midLength.closest("&lt;br&gt;, &lt;/p&gt;, &lt;br/&gt;").append("Ad Codes Come Here");
  
  });
  </code></pre>