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 -

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

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -