如何使用JavaScript从textarea中删除HTML标记

Mat*_* B. 2 html javascript url jquery textarea

我正在从数据库加载文本,但我想用JavaScript删除它的html链接代码.

那么让我们说textarea现在显示:

<a rel="nofollow" href="http://stackoverflow.com//questions/ask">http://stackoverflow.com//questions/ask</a> - good page 
Run Code Online (Sandbox Code Playgroud)

我希望它显示:

http://stackoverflow.com//questions/ask - good page
Run Code Online (Sandbox Code Playgroud)

我可以使用哪些轻量级的东西适用于同一textarea中的多个链接?

Yah*_*hel 8

受此答案的启发,使用浏览器的HTML解析功能来正确完成此操作.

function strip(html)
{
   var tmp = document.createElement("DIV");
   tmp.innerHTML = html;
   return tmp.textContent||tmp.innerText;
}
jQuery('#textareaid').text(function(index, text){
 return strip(text);
});
Run Code Online (Sandbox Code Playgroud)

这是它工作的JSFiddle:http://jsfiddle.net/Au95R/1/

(编辑使用清洁JS)