001
001

Reputation: 65087

jquery click on link?

After an event is triggered, how do I make jQuery click on a link with an id of mylink?

Upvotes: 1

Views: 454

Answers (3)

Dave Ward
Dave Ward

Reputation: 60580

Calling click() without any parameters triggers the event, instead of registering an event handler for it.

$('#mylink').click();

Upvotes: 2

Sophie Alpert
Sophie Alpert

Reputation: 143114

You probably want something like

window.location = $("#mylink").attr("href");

Upvotes: 0

meder omuraliev
meder omuraliev

Reputation: 186562

$('#lol').click(function() {
   $('#mylink').trigger('click')
   return false;
});

replace click with your event.

Upvotes: 2

Related Questions