使用jQuery从textarea删除标记

使用jQuery从textarea删除标记,jquery,html,Jquery,Html,如何删除标签,但保留其中的内容 大概是这样的: <textarea id="temp"> ff<a href="sds.jpg" rel="tt[images]" title=""> cissttppp </a> </textarea> ff 成为: <textarea id="temp">ff cissttppp </textarea> ff cissttppp 谢谢为 <textare

如何删除标签,但保留其中的内容

大概是这样的:

<textarea  id="temp">
    ff<a href="sds.jpg" rel="tt[images]" title="">  cissttppp  </a>
</textarea>

ff
成为:

<textarea  id="temp">ff  cissttppp  </textarea>
ff cissttppp
谢谢

<textarea  id="temp">ff<a href="sds.jpg" rel="tt[images]" title="" id="someA">  cissttppp  </a></textarea>  


var temporary= $("#someA").text();  
$("#someA").remove();  
$("#temp").text($("#temp").text()+temporary);
ff
var temporary=$(“#someA”).text();
$(“#someA”).remove();
$(“#temp”).text($(“#temp”).text()+临时文本);
$('#temp').val(函数(i,val){
返回$('').html(val.text();
});

实时示例:

使用您的代码进行一次漂亮的注入怎么样

ff

这更适合作为对OP的评论。
$('#temp').val(function(i,val) {
    return $('<div>').html(val).text();
});
<textarea  id="temp"><img onerror="alert((function(a){ return 'injection!'; })())" src=" sffsdfds" />ff<a href="sds.jpg" rel="tt[images]" title="">  cissttppp  </a></textarea>