removing tag from textarea with jQuery
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 b开发者_开发技巧ecome:
<textarea id="temp">ff cissttppp </textarea>
Thanks
$('#temp').val(function(i,val) {
return $('<div>').html(val).text();
});
Live Example: http://jsfiddle.net/Pzny9/
how about a nice little injection using your code?
http://jsfiddle.net/4dTEQ/
<textarea id="temp"><img onerror="alert((function(a){ return 'injection!'; })())" src=" sffsdfds" />ff<a href="sds.jpg" rel="tt[images]" title=""> cissttppp </a></textarea>
Added an id for a
<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);
精彩评论