Support

Account

Home Forums Backend Issues (wp-admin) Phone field with href="tel:" link Reply To: Phone field with href="tel:" link

  • Good morning @brevalo,

    The reason why you want the script at the end is that the page needs to load first so that the script can find what to change. If you put the script on top, then the script will execute first before the page loads and won’t find anything to change.

    Exclamation marks? There are no exclamation marks in the script. You have to be careful with the quote marks ” “. Single and double quotation marks are common ‘ ‘ or ” “. Below is the script that I used for the ACF links.

    <script>
    (function($){
    $(“.phoneButton a”).attr(“href”, function ( index, currentvalue) {
    var url_format = currentvalue.replace(/(^\w+:|^)\/\//, “”);
    $(this).attr(“href”, “tel:” + url_format);
    });

    })(jQuery);
    </script>