JSFiddle - React, Tailwind, and code Playground

by Nicolas PUJOL

HTML

<div class="tree">
    <div class="item">
        <!-- replaced OK --> <a href="" class="toggle">+</a>
 <a href="" class="name">Name</a>

        <div class="collapse">
            <div class="item">ghjghj
                <!-- this wouldn't be replaced ?! -->
            </div>
        </div>
    </div>
    <div class="item"></div>
    <!-- replaced OK -->
</div>

JavaScript

$('.tree').find($('.item')).each(function( index ) {
    $(this).replaceWith($("<li>").append($(this).contents()));
});