Initially, I assumed this task would be straightforward using Javascript. However, I quickly realized my mistake: Within the TinyMCE iframe body, I have the following HTML code:
<ul>
<li><a href="#">First</a></li>
<li><a href="#">Second</a></li>
<li><a href="#">Third</a></li>
</ul>
My goal is to place the cursor after the word "Second" and upon clicking a button, trigger an onclick-function that inserts a new "LI" element AFTER the "Second" list item, resulting in the following updated structure:
<ul>
<li><a href="#">First</a></li>
<li><a href="#">Second</a></li>
<li><a href="#">New inserted list item</a></li>
<li><a href="#">Third</a></li>
</ul>
It's worth noting that the LI-tags do not have any ID or class assigned to them, ruling out the use of getElementById. This limitation is where I encounter difficulties. (Furthermore, this functionality takes place within a TinyMCE editor textarea, though this detail shouldn't impact the overall approach.)