0

Is there a way to click an anchor tag inside another event. What I have here does not seem to work:

jsfiddle: http://jsfiddle.net/my7oxtL0/1/

JS:

$('.mybutton').click(function(){
    //other stuff runs
    $("#link1").click();
});

html:

<button class="mybutton">click me</button>
<a id="link1" href="http://www.google.com" target="_blank"></a>
Chipe
  • 4,641
  • 10
  • 36
  • 64

2 Answers2

0

Try this,

$('.mybutton').click(function(){
    //other stuff runs
    document.getElementById("link1").click();
});
Varun
  • 1,946
  • 2
  • 11
  • 17
0

Let me know why you are trying anchor tag click in here ? You can try with window.open() method to do

Window.open($("#anchor").attr('href'));
user3468621
  • 347
  • 1
  • 3
  • 10