I'm trying to replace all HREF with domain1.com with the URL described in his title (if it has a title).
var els = document.getElementsByTagName('a'),
  for (els in url) {
    if (url.includes(domain1)); {
      var titulo = url.attr('title');
      var enlace = url.attr('href');
      url.replace(enlace, titulo);
    }
  }<p style="margin:40px;" line-height:2px;=""><img src="https://www.domain1.com/738956_1.jpg" data-width="1070" data-height="1387" data-image="738956-sanKH" alt="738956-sanKH.jpg">XS <a href="https://www.domian1.com/plants" target="_blank" class="link" rel="nofollow noopener" title="https://www.newdomain.com/test1">texto</a><br>
  <img src="https://www.domain1.com/738956_1.jpg" data-width="1077" data-height="1693" data-image="738956-iMkWh" alt="738956-iMkWh.jpg">S <a href="https://www.domain1.com/flowera" target="_blank" class="link" rel="nofollow noopener" title="https://www.newdomain.com/test2">texto</a></p>I'm a beginner in javascript. Sure have a lot of format mistakes. Thanks in advance
 
     
     
    