How to spoof a click in jQuery

793 Views Asked by At

I want to try and find a way to spoof a click with jQuery/Javascript.

Basically I have an image wrapped in an tag. When I click this I want the browser to think it has clicked a different link and run that instead.

I have lightbox activated on the click of $('.gallery a') I want to click one image but have lightbox think I've clicked another and open that up in the lightbox instead.

4

There are 4 best solutions below

0
On

Try doing this.

$('.gallery a').click();
0
On

just do $('#selector').click()

0
On

Just call the click event.

in this case

$(".gallery a").click();
0
On
event.preventDefault();
$("other_link").trigger("click");