Handle swipt left event

Description

The following code shows how to handle swipt left event.

Example


<!--from w  w  w  .j a  va 2  s  .  c  o m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.1.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css">
<script type='text/javascript'
  src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>
<style type='text/css'>
.add-border {
  border-style: solid;
  border-width: 1px;
  width: 100%;
  text-align: center;
}
</style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
function bindEvent(element) {
    element.bind('tap taphold swipe swiperight swipeleft', function(event, ui) {
       alert('Event: '+event.type); 
    });
}
bindEvent($('#display-event'));
});//]]>  
</script>
</head>
<body>
  <div data-role="page" id="home">
    <div data-role="content">
      <div id="display-event" class="add-border">
        <p>Tap, TapHold (for 1 second), Swipe, SwipeRight or SwipeLeft</p>
      </div>
    </div>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme