I have a variable that contains a string of text and html tags, such as:
var temp = \"Some textMore texthere>
Demo: http://jsfiddle.net/VwTHF/1/
$('span, p').contents().unwrap();
.contents() will get the elements and text within each such tag, and .unwrap will remove the element wrapping each content section.
Based on your current approach it would look something like this:
var temp = "Some textMore texthere
Even more
";
var $temp = $(temp);
$temp.find('span, p').contents().unwrap().end().end();
If you want to continue targeting the original object, you have to use .end()
to clear the filter.