How to programmatically trigger the click on a link using jQuery?

$('#your_link_id').click()

See the excellent jquery docs for more information


If you have an anchor link:

<a id="my_link_id" href="something">My Link</a>

it will fail as other answers have mentioned. Calling .eq and .trigger('click') doesn't work for me, but this does:

$('#your_link_id').get(0).click();

In my specific case, I've assigned a blob url programmatically to the anchor's href.


You can use trigger:

$('#your_link_id').trigger('click');

$('#your_link_id')[0].trigger('click');

is needed as jQuery returns an array and we cannot trigger click on multiple eventlinks. You have to target only a single element