En esta parte veremos como crear elementos checkbox buttons y un ejemplo a través de jQuery para comprobar el estado del checkbox, activado-desactivado.
Código del capítulo. checkbox-buttons.php ...
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Checkbox Buttons</title> <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.4.5.css"> <script src="jquery.mobile/jquery.js"></script> <script src="jquery.mobile/jquery.mobile-1.4.5.js"></script> </head> <body> <div data-role="page" data-theme="a"> <div data-role="header"> <h1>Checkbox Buttons</h1> </div> <div data-role="main"> <div class="ui-content"> <script> $(function(){ $("#btn").on("click", function(){ if ($("input[name='terminos']").is(":checked")) { $("#resultado").html("¡Has aceptado los términos!"); } else { $("#resultado").html("¡Error, no has aceptado los términos!"); } }); }); </script> <form method="POST"> <fieldset> <label> <input type="checkbox" name="terminos">Aceptar los términos </label> </fieldset> <button type="button" id="btn">Validar</button> </form> <div id="resultado"></div> </div> </div> <div data-role="footer"> <div class="ui-content"> <small>© Tutorial jQuery Mobile</small> </div> </div> </div> </body> </html>
Tutorial completo de jQuery Mobile en Youtube
No hay comentarios:
Publicar un comentario