How to disable link to phone number when on Desktop?

后端 未结 20 937
清酒与你
清酒与你 2021-02-03 23:47

How can I add a phone number to a website that is clickable but hides the link when I\'m browsing on a website that doesn\'t support touch.

I could use Modernizr to set

20条回答
  •  伪装坚强ぢ
    2021-02-04 00:02

    In my target site, all phone link markups are in this pattern: 111-222-3333. My solution is such simple:

    function setPhoneLink() {
        if (screen.width > 640) {
            $("a[href^='tel:']").each(function(){
                $(this).replaceWith($(this).text());
            });
        }
    } 
    

    Device-width: mobile<640; tablet >=768 and <1024; desk >=1024. Source: http://javascriptkit.com/dhtmltutors/cssmediaqueries2.shtml

提交回复
热议问题