How to Click to show & Click to call?

时光毁灭记忆、已成空白 提交于 2020-06-16 05:29:52

问题


I'm using this to click to show a phone number but I want to make a click to call after showing the phone number. Any tips? Thanks in advance!

<span id="number" data-last="123-456-7896"><span>
<a class="see">(718)... Click to show </a></span>

$('#number').click(function() {
$(this).find('span').text( $(this).data('last') );

回答1:


You need to insert a link with a tel: or a callto: scheme upon click.

For example:

$('#number').click(function() {
    var tel = $(this).data('last');
    $(this).find('span').html( '<a href="tel:' + tel + '">' + tel + '</a>' );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="number" data-last="+1234567896">
  <span><a class="see">(718)... Click to show </a></span>
</span>


来源:https://stackoverflow.com/questions/41750706/how-to-click-to-show-click-to-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!