滑动以重定向到类next的超链接的href位置

Swipe to redirect to href location of hyperlink with class next

本文关键字:超链接 href 位置 next 重定向      更新时间:2023-09-26

我正在寻找一种方法来使用常规的jquery库捕获滑动事件(左,右)重定向到一个特定的类(默认导航)指定的位置。(例如:.next和.previous)。

<a class="next" href="http://www.">next</a>
<a class="previous" href="http://www.">previous</a>
$("body").on('swipeleft', function(e) {
  window.location.replace( $(".previous").attr('href') );
});
$("body").on('swiperight', function(e) {
  window.location.replace( $(".next").attr('href') );
});

示例:http://stephband.info/jquery.event.swipe/