1

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.

Antonio Moore
  • 930
  • 4
  • 14
  • 21

4 Answers4

1

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

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
0

Try doing this.

$('.gallery a').click();
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
0

Just call the click event.

in this case

$(".gallery a").click();
Mark Broadhurst
  • 2,675
  • 23
  • 45
0
event.preventDefault();
$("other_link").trigger("click");
Jonas Geiregat
  • 5,214
  • 4
  • 41
  • 60