用jquery删除所有html标签?

如何在jquery中去掉所有的html标签。 像PHP中的strip_tags这样的函数

例如:有以下内容:

This is bold and this
is
italic.

现在我想将其更改为

This is bold and this is italic.

使用.text()

 $('#test').text($('#test').text()); 

我使用.text()两次因为使用.html()来设置内容会导致字符串小于和大于符号被错误地呈现:

 Hello <foo> // Set with .text() Hello  // Set with .html() 

如果您使用.html() ,则将成为标记。