0
Imagine you have a parent element with children where the class represents a text selection:
<span class="item-1" data-id="1">texto selecionado 1
<span class="item-2" data-id="2">texto selecionado 2
<span class="item-3" data-id="3">parte do texto 3</span>
</span>parte do texto 1
</span>
How could I make these elements stay this way, with some method in Javascript:
<span class="item-1" data-selection="1" data-id="1">texto selecionado 1</span>
<span class="item-2" data-selection="2" data-id="2">texto selecionado 2</span>
<span class="item-3" data-selection="3" data-id="3">parte do texto 3</span>
<span class="item-1" data-selection="4" data-id="1">parte do texto 1</span>