I\'ve got some html that looks like this:
red text some more text blue text
Wouldn't a simple $('#my-div').text ($('#my-div').text ())
suffice, without resorting to unwrapping?
$(mydiv).html($(mydiv).text())
should do the trick.
You don't want to unwrap the span, you want to unwrap its contents:
$("span").contents().unwrap();
Online Demo: http://jsbin.com/iyigi/edit
For earlier versions of jQuery, you could do the following:
$("span").replaceWith(function () {
return $(this).text();
});
Online Demo: http://jsbin.com/iyigi/40/edit