2

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') );
Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
Elliot
  • 41
  • 5

1 Answers1

2

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>
Community
  • 1
  • 1
Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103