Saturday, 31 August 2013

Jquery - Using Touch Swipe to Check Radio Buttons

Jquery - Using Touch Swipe to Check Radio Buttons

So I have a CSS3 slides setup with radio buttons to trigger the next
slide. I want to be able to add touch/swipe to it for tablets and phones
(i.e. swipe left and and the next radio gets checked).
The jQuery I'm trying to use:
$(document).ready(function() { $("#cover").swipeleft(function(event){
$('input:radio[class=slide_2]').attr("checked", true); });
$("#cover2").swiperight(function(event){
$('input:radio[class=slide_1]').attr("checked", true); });
$("#cover2").swipeleft(function(event){
$('input:radio[class=slide_3]').attr("checked", true); });
$("#ingredients").swiperight(function(event){
$('input:radio[class=slide_2]').attr("checked", true); });
$("#ingredients").swipeleft(function(event){
$('input:radio[class=slide_4]').attr("checked", true); });
$("#directions").swiperight(function(event){
$('input:radio[class=slide_3]').attr("checked", true); }); });
http://jsfiddle.net/hakarune/ZsrdP/1/ Here's the whole setup and my
jQuery, but it doesn't work at all. Anyone have an idea how to fix it?

No comments:

Post a Comment