title: Replace DOM Element with Opening Tag Only (or Closing Tag)
body: <p>I use Blogger as my blogging platform. Annoyingly, hitting enter in the Rich Text Editor creates &lt;br /&gt; (line break) tags instead of &lt;p&gt;&lt;/p&gt; (paragraph tags). Unfortunately I have found no means of switching this within the Blogger platform.</p>
  
  <p>So my solution is to use jQuery to replace every even &lt;br /&gt; tag with an opening &lt;p&gt; tag and every odd &lt;br /&gt; with a closing &lt;/p&gt; tag like below.</p>
  
  <pre><code>&lt;br /&gt; (replace with &lt;p&gt;)
  Some initial paragraph
  &lt;br /&gt; (replace with &lt;/p&gt;)
  &lt;br /&gt; (replace with &lt;p&gt;)
  Some second paragraph
  &lt;br /&gt; (replace with &lt;/p&gt;)
  &lt;br /&gt; (replace with &lt;p&gt;)
  Some third paragraph
  &lt;br /&gt; (replace with &lt;/p&gt;)
  </code></pre>
  
  <p>To do this, I wrote the below jQuery.</p>
  
  <pre><code>$("br").each(function(i){
      if (i % 2 === 0){
          $(this).replaceWith("&lt;p&gt;");
      } else {
          console.log("odd break");
          $(this).replaceWith("&lt;/p&gt;");
      }
  })
  </code></pre>
  
  <p>However, instead of getting my results above, I instead found that each &lt;br /&gt; tag was replaced with both an opening and closing tag &lt;p&gt;&lt;/p&gt;</p>
  
  <p>Any suggestions as to how I can go about doing this?</p>
  
  <p>Thanks!</p>
  
  <p>(And please do not suggest that I switch to another blogging platform that actually does what I intend. I do not wish to do that nor does it actually answer my question.)</p>