Skip to content

Instantly share code, notes, and snippets.

@ericmann
Created May 21, 2012 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericmann/2765331 to your computer and use it in GitHub Desktop.
Save ericmann/2765331 to your computer and use it in GitHub Desktop.
Set up images like this:
<div id="raffle">
<img src="..." data-link="http://link.url" />
<img src="..." data-link="http://link.url" />
</div>
Then set up a JS event listener:
jQuery('#raffle').on('click', 'img', function(e) {
var href = $(this).data('link');
window.location = href;
});
This lets you bind an event listener to the entire slide show and simulate link clicks ...
without actually using `<a>` tags.
More on event delegation here: http://jumping-duck.com/tutorial/javascript-event-listeners/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment