trigger a href sip/tel link on button click jquery

6.7k Views Asked by At

I'm trying to trigger a click event that will open my href sip/tel link when user clicks the button, but it doesn't trigger the click event after the button has been pressed.

jquery code:

$('#next_button').click(function() {
       var num = $(this).val();
       $('#call-num'+num).trigger('click');
       alert(num);
});

href code:

<a href="tel:001(999) 888-3333" id="call-num1">(999) 888-3333</a>
<button id="next_button" value="1">Next</button>
1

There are 1 best solutions below

2
On BEST ANSWER
$('#next_button').on('click', function() {
      var num = $(this).val();
      var call = $('#call-num'+num).attr('href');
      location.href = call;
      alert(call);
});