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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

SQL Server - MyCTE query based on 24 hour period (next day) -

php - Using str_replace to translate a MySQL Table in html -