How to remove http:// using jQuery (WordPress)?

Solution:1

The following script should get the current value of the href attribute of the link element inside the elementor-button-wrapper div, remove the http:// string or replace it with blank, then apply the newlink back to the link’s href attribute.

 

jQuery(".elementor-button-wrapper").each(function(){
        var link = jQuery(this).find("a");
        var newlink = link.attr("href").replace('http://', '');
        link.attr("href", newlink);
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="elementor-button-wrapper">
<a href="http://https://www.myweb.com/hereis" class="elementor-button-link elementor-button elementor-size-sm" role="button">
    <span class="elementor-button-text">Read More</span>
</a>
</div>

Solution:2

You could try this.

 

function FormatLink(link, keyword) {
  var index = link.indexOf(keyword);
  if (index === -1) {
    return link;
  }
  return link.slice(0, index) + link.slice(index + keyword.length);
}

$("a").each(function() {
  if ($(this).attr("href").indexOf("http://") != -1) {
    var link = FormatLink($(this).attr("href"), 'http://');
    $(this).attr("href", link);
    console.log(link);
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="elementor-button-wrapper">

  <a href="http://https://www.myweb.com/hereis" class="elementor-button-link elementor-button elementor-size-sm" role="button">
    <span class="elementor-button-text">Read More</span>
  </a>
  
  <a href="http://https://www.myweb.com/hereis" class="elementor-button-link elementor-button elementor-size-sm" role="button">
    <span class="elementor-button-text">Read More</span>
  </a>
  
  <a href="https://www.myweb.com/hereis" class="elementor-button-link elementor-button elementor-size-sm" role="button">
    <span class="elementor-button-text">Read More</span>
  </a>
  
</div>