我正在尝试创建一个像iphone上的滑动复选框。
我从这个脚本开始:
$('input[type=checkbox]').live('touchstart', function (e) {
down_x = e.originalEvent.touches[0].pageX;
$('input[type=checkbox]').live('touchmove', function (e) {up_x = e.originalEvent.touches[0].pageX;
if ((down_x - up_x) > 1) {$(this).change()}});
});
但它似乎没有用。有关如何实现这一点的任何想法?
这是一个有趣的小问题
我让它工作得很好,它甚至可以用鼠标:)
我在我的Ipad和Iphone上进行了测试,非常酷。
不会花太多工作把它翻成插件,但这对你来说应该没问题
使用ios移动事件的诀窍是这三个事件
$('.toggle_box').bind('touchstart',touch_start);
$('.toggle_box').bind('touchmove',touch_move);
$('.toggle_box').bind('touchend',slide_end);
http://jsfiddle.net/samccone/ZMkkd/
这是一个有趣的小问题
我让它工作得很好,它甚至可以用鼠标:)
我在我的Ipad和Iphone上进行了测试,非常酷。
不会花太多工作把它翻成插件,但这对你来说应该没问题
使用ios移动事件的诀窍是这三个事件
$('.toggle_box').bind('touchstart',touch_start);
$('.toggle_box').bind('touchmove',touch_move);
$('.toggle_box').bind('touchend',slide_end);
http://jsfiddle.net/samccone/ZMkkd/