用jQuery从textarea中删除标签 [英] removing tag from textarea with jQuery
本文介绍了用jQuery从textarea中删除标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何删除标签,但其中的内容仍然存在?
类似这样:
< textarea id =temp>
ff< a href =sds.jpg =tt [images]title => cissttppp< / a>
< / textarea>
成为:
< textarea id =temp> ff cissttppp< / textarea>
谢谢
解决方案 ($,$ div'')。html(val){pre'$'code> $('#temp')。 .text();
});
});
直播示例: http://jsfiddle.net/Pzny9/
How to remove the a tag but the content in it to remain?
Something like this:
<textarea id="temp">
ff<a href="sds.jpg" rel="tt[images]" title=""> cissttppp </a>
</textarea>
To become:
<textarea id="temp">ff cissttppp </textarea>
Thanks
解决方案
$('#temp').val(function(i,val) {
return $('<div>').html(val).text();
});
Live Example: http://jsfiddle.net/Pzny9/
这篇关于用jQuery从textarea中删除标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文