Evento de deslizar hacia la izquierda de jQuery Mobile

El evento swipeleft de jQuery Mobile se activa cuando deslizamos el dedo hacia la izquierda en el área del elemento. Podemos utilizar este evento para diferentes propósitos.

Sintaxis:

jQuery( ".selector" ).on( "swipeleft", function( event ) {  } )

Enfoque: Primero, agregue los scripts móviles de jQuery necesarios para su proyecto.

<enlace rel=”hoja de estilo” href=”http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css” />
<script src=”http://code .jquery.com/jquery-1.11.1.min.js”></script>
<script src=”http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min .js”></secuencia de comandos>

Ejemplo 1:

HTML

<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" href=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
  
    <script src=
        "http://code.jquery.com/jquery-1.11.1.min.js">
    </script>
  
    <script src=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
    </script>
  
    <script type="text/javascript">
        $(document).on('swipeleft', 'a', function() {
            console.log('swipeleft event fired');
        })
    </script>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h4>swipeleft Event using jQuery Mobile</h4>
    </center>
  
    <a data-role="button" id="gfg">click</a>
</body>
  
</html>

Producción:

Ejemplo 2:

HTML

<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" href=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
  
    <script src=
        "http://code.jquery.com/jquery-1.11.1.min.js">
    </script>
  
    <script src=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
    </script>
  
    <script type="text/javascript">
        $(document).on('swipeleft', 'a', function(event) {
            console.log(event)
        })
    </script>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h4>swipeleft Event using jQuery Mobile</h4>
    </center>
  
    <a data-role="button" id="gfg">click</a>
</body>
  
</html>

Producción:

Publicación traducida automáticamente

Artículo escrito por taran910 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *