To remove just the tags, and not the content, which is how PHP’s strip_tags()
behaves, you can do:
var whitelist = "p"; // for more tags use the multiple selector, e.g. "p, img"
$("#text *").not(whitelist).each(function() {
var content = $(this).contents();
$(this).replaceWith(content);
});