Mark Henry
Mark Henry

Reputation: 2699

Swipe to redirect to href location of hyperlink with class next

I am looking for a way to use the regular jquery library to catch swipe events (left, right) to redirect to a href-location specified with a particular class (default navigation. ie: .next and .previous).

<a class="next" href="http://www.">next</a>

<a class="previous" href="http://www.">previous</a>

Upvotes: 2

Views: 1745

Answers (1)

sanchez
sanchez

Reputation: 4530

$("body").on('swipeleft', function(e) {
  window.location.replace( $(".previous").attr('href') );
});

$("body").on('swiperight', function(e) {
  window.location.replace( $(".next").attr('href') );
});

Example: http://stephband.info/jquery.event.swipe/

Upvotes: 2

Related Questions