简体   繁体   English

如何在锚标签中传递变量

[英]How to pass variable in anchor tag

I am using this anchor tag to make a call in android using cordova.我正在使用这个锚标记使用cordova在android中进行调用。

<a class="lft" href="tel:7767051447">Call</a>

Instead of number i want to give variable value.我想给变量值而不是数字。

I have number in我有号码

var phone_no

How do i pass variable instead of static number?我如何传递变量而不是静态数字?

You could give the anchor an id:你可以给锚一个id:

<a class="lft" href="tel:7767051447" id="phone">Call</a>

and then update the href attribute:然后更新href属性:

var phone_no = '12345';
document.getElementById('phone').href = 'tel:' + phone_no;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM