如何刪除標籤,但其中的內容仍然存在?使用jQuery從textarea中刪除標籤
事情是這樣的:
<textarea id="temp">
ff<a href="sds.jpg" rel="tt[images]" title=""> cissttppp </a>
</textarea>
要成爲:
<textarea id="temp">ff cissttppp </textarea>
感謝
如何刪除標籤,但其中的內容仍然存在?使用jQuery從textarea中刪除標籤
事情是這樣的:
<textarea id="temp">
ff<a href="sds.jpg" rel="tt[images]" title=""> cissttppp </a>
</textarea>
要成爲:
<textarea id="temp">ff cissttppp </textarea>
感謝
$('#temp').val(function(i,val) {
return $('<div>').html(val).text();
});
一個id
增加了對
<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);
如何使用您的代碼一個很好的小注射?
<textarea id="temp"><img onerror="alert((function(a){ return 'injection!'; })())" src=" sffsdfds" />ff<a href="sds.jpg" rel="tt[images]" title=""> cissttppp </a></textarea>
這會更佔有爲在OP評論。 – 2016-07-26 16:00:49
短期和甜蜜 - 仍然偉大工程,兩年多後 – 2013-08-31 10:26:13