Remove all text between div without losing text outside of it - jQuery JS
2 answers
You can use after
to insert inner text after the div and then remove it:
var $foo = $(".foo");
$foo.after($foo.text()).remove();
Or, you can use a function replaceWith
to replace the div element with your inner text content:
$foo.replaceWith($foo.text());
+1
source to share