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
Post a Comment