问题
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