【发布时间】:2014-08-12 10:40:44
【问题描述】:
我正在尝试使用 Matt Bryson 的 Jquery touchSwipe 插件 (https://github.com/mattbryson/TouchSwipe-Jquery-Plugin) 在一组单选按钮中前进以显示/隐藏页面上的内容。
我真的只需要它转到左滑动的下一个单选按钮和右滑动的上一个单选按钮,并尝试尽可能概括,以便它与同一页面上的许多按钮组一起使用。
理想情况下,我想将它附加到按钮组的名称上,而不是与正在显示的事物相关联的特定 ID 或类,但我似乎无法让它工作。如果有人对如何实现这一点有任何想法,我将不胜感激!
我的代码如下。注释掉的“you swipe...”行是演示中的原始事件,并且确实有效...
$(function() {
//Enable swiping...
$("#log1").swipe( {
//LEFT SWIPE
swipeLeft:function(event, direction, distance, duration, fingerCount, fingerData) {
//$(this).text("You swiped " + direction );
$("input:radio[name=log1-slab-selector]").next(":checked")
},
//RIGHT SWIPE
swipeRight:function(event, direction, distance, duration, fingerCount, fingerData) {
//$(this).text("You swiped " + direction );
$("input:radio[name=log1-slab-selector]").prev(":checked")
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:0
});
});
【问题讨论】:
标签: javascript jquery button radio next