【问题标题】:Swipe to redirect to href location of hyperlink with class next滑动以重定向到带有下一个类的超链接的 href 位置
【发布时间】:2013-06-05 13:51:03
【问题描述】:

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

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

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

【问题讨论】:

  • jquery 支持滑动。只需在滑动事件上添加一个监听器并重定向用户

标签: javascript jquery swipe


【解决方案1】:
$("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/

【讨论】:

  • 问题是它必须遵循特定类中 href 的 url。它不能是静态 URL。
  • 当我滑动时,这在平板电脑上不起作用。我用这个:&lt;a id="next-link" class="next" href="link"&gt;text&lt;/a&gt;我做得对吗?
猜你喜欢
  • 2018-03-09
  • 2012-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-28
  • 1970-01-01
相关资源
最近更新 更多