Question

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>
Was it helpful?

Solution

$('#next_button').on('click', function() {
      var num = $(this).val();
      var call = $('#call-num'+num).attr('href');
      location.href = call;
      alert(call);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top