javascript - JS Regex to replace all html tags -


i have spent while researching , cant find solution, looking method remove html tags string , if img tags appear, replace them src attribute, sorry little information. thanks.

i think might need:

var str = "<b>test</b> <p><img src='path.png' /> boom <span>sss</span></p>";    var text = $(str).find('img').replacewith(function() {      return $(this).attr('src');  }).end().text();    alert(text);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -