简体   繁体   中英

How to pass variable in anchor tag

I am using this anchor tag to make a call in android using cordova.

<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:

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

and then update the href attribute:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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