JS 獲取Html字符串中的img標簽替換src內容『轉』


<script type="text/javascript">
var newContent= content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi,function(match,capture){

  //capture,返回每個匹配的字符串
  var newStr='<img src="http://www.csghj.gov.cn'+capture+'" alt="" />';
  return newStr;
});
console.debug(newContent);
</script>

轉自:http://blog.csdn.net/burongwawa520/article/details/46562015

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM