I want to fire hyper link through javascript. It link must be open in new tab.
We can use window.open(‘url’) but we know browser blocks popup. So i need alternate solution for it.
I have tried with trigger() but it doesn’t work.
My HTML code is :
<input id="btn" type="button" value="Click to fire">
<a id="link" href="http://www.google.com" target="_blank">Link</a>
My script is :
$('#btn').click(function(){
$('#link').trigger('click');
});
Besides i used click(), it doesn’t work too.
Code is :
$('#btn').click(function(){
$('#link').click();
});
Can you any one help me?
Here is your solution – http://jsfiddle.net/svTWu/1/
Here is the code
Here you can read all information about trigger – http://api.jquery.com/trigger/