javascripthtmltextunwrappreserve

How to unwrap spans with empty class-Names <span class="">assign </span>?


Does anybody has an idea to remove the <span class="">TEST</span> with jquery or javascript? The innerHTML hier "TEST" shall be preserved. Looks easy but i didn't find an easy way.


Solution

  • I would try this:

    $('span[class=""]').each(function() {
        $(this).replaceWith(this.childNodes);
    });
    

    But if you really wanna use unwrap you could use:

    $('span[class=""]').each(function() {
        $(this.childNodes).unwrap();
    });