I have a string that looks like this:
var txtstr='<p>Text 1</p><p> </p><p>Text 2</p><p> </p><p>Text 3 </p>';
I have an <img src=..../>
tag and I want to insert it at a specific position within a p tag.
For example, let's say the 5th <p>
tag and after the 7th character. Here, each
will count as one character only, even if there are multiple instances of
.
I tried doing something like this:
const paragraphs = str.split("</p>")
const firstParagraph = paragraphs[5]+'</p>';
but unfortunately, this method did not work as expected.
If anyone has a solution, I would greatly appreciate it. Thank you!