Onclick更改文本和电话

时间:2016-01-24 16:04:19

标签: javascript href tel

点击

显示电话号码的脚本
 <script>
    function changeText(id) {
    id.innerHTML = "<?php echo $phone ?>"
    }
    </script>

href

$STRING .= '<a href="tel:" onclick="changeText(this)" class="btn btn-info btn-lg"></a>';

点击它会显示$ phone,但它无法调用。

如何透露和调用它?

1 个答案:

答案 0 :(得分:0)

您无法点击锚点来拨打该号码,因为该号码永远不会添加到href中,您想要的是一个看起来像function changeText(id) { id.innerHTML = "<?php echo $phone ?>"; id.href = "tel:<?php echo $phone ?>"; } 等的href。

       var that = this
       $.when(
            that.functionA(param1,that) ,
            that.functionB(param1,that)  ,
            that.functionC(that)  ,
            that.functionD(param1,that)  ,
            that.functionE(param1,that) ,
            that.functionF(param1,that, param2)
        ).done(function( a1, a2 , a3, a4, a5, a6) {
            var response1 = jQuery.parseJSON(a1[0].result.results);
            var response2 = jQuery.parseJSON(a2[0].result.results);
            var response3 = jQuery.parseJSON(a3[0].result.results);
            var response4 = jQuery.parseJSON(a4[0].result.results);
            var response5 = jQuery.parseJSON(a5[0].result.results);
            var response6 = jQuery.parseJSON(a6[0].result.results);

            that.view = new MyView({
                someParam:param1,
                anotherParam:param2,                    
                r1: response1,
                r2: response2,
                r3: response3,
                r4: response4,
                r5: response5,
                r6: response6
            }),

            window.app.page(that.view, {
                tab:'someValue',           
            })
    });