I want to wrap the sentences individually with new tag within <p>. How can I do that using JQuery? I know I can do this with $(p).contents().eq(2).wrap('<span/>') and $(p).contents().eq(4).wrap('<span/>'), but this is hardcoded. The number of sentences in the paragraph I have are dynamic.
<!-- How do I change this -->
<p>
  <span>1</span>
  This is the 1st sentence.
  <span>2</span>
  This is the 2nd sentence.
</p>
<!-- to become this? -->
<p>
  <span>1</span>
  <span>This is the 1st sentence.</span>
  <span>2</span>
  <span>This is the 2nd sentence.</span>
</p>