0
  1. En el código que tengo abre el calendario en el botón en el que se dio click, pero quiero que lo abra en donde se va a ver la modificación de la fecha
<html lang="es">
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

        <script>
            $(document).ready(function(){
                $( ".fecha, .abrir-calendario-arriba" ).datepicker();
            });
        </script>
    </head>
    <body>

        <p><input type="submit" class="fecha" id="datepicker" value="Fecha"></p>
        <p><input type="submit" class="abrir-calendario-arriba" id="datepicker" value="Cambiar y abrir el calendario en el boton de arriba"></p>

    </body>
</html>

2 respuestas 2

0

En primer lugar, debes cambiarle el ID, pues está repetido y, finalmente, hacer que cuando cliques en él, enseñe el que deseas. La idea sería algo así:

<p><input type="submit" class="abrir-calendario-arriba" id="datepicker_aux" value="Cambiar y abrir el calendario en el boton de arriba"></p>

<script>
   $("#datepicker_aux").click( function() {
       $("#datepicker").show();
   });
</script>
0

Me funciono hacer esto


    <!DOCTYPE html>
    <html>
    <head>
      <title></title>
    </head>
    <body>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.js"></script>
    <style type="text/css">
      .back{
        background: #000;
        font-weight: 700;
        font-size: 50px;
        color: #fff;
      }
    </style>
    <script type="text/javascript">


      $(function() {
          $.datepicker.regional['es'] = {
          closeText: 'Cerrar', 
          prevText: 'Previo', 
          nextText: 'Próximo',

          monthNames: ['de Enero','de Febrero','de Marzo','de Abril','de Mayo','de Junio', 'de Julio','de Agosto','de Septiembre','de Octubre','de Noviembre','de Diciembre'],
          monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun', 'Jul','Ago','Sep','Oct','Nov','Dic'],
          monthStatus: 'Ver otro mes', yearStatus: 'Ver otro año',
          dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],
          dayNamesShort: ['Dom','Lun','Mar','Mie','Jue','Vie','Sáb'],
          dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sa'],
          dateFormat: 'DD dd MM yy', firstDay: 0, 
          initStatus: 'Selecciona la fecha',
          isRTL: false
        };
          $.datepicker.setDefaults($.datepicker.regional['es']);
          $( "#datepicker" ).datepicker({ minDate: "-5Y", maxDate: "+0D" });
          $('#ui-datepicker-div').css('clip', 'auto');

              $("#open-datepicker").click(function() {
                $("#datepicker").datepicker("show");
                $('html, body').animate({
                  scrollTop: 0
                }, 1500, 'easeInOutExpo');
                return false;
              });
      });

    </script>

    <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet"/>

    SELECCIONAR:&nbsp;&nbsp;
    <input type="submit" id="datepicker" value="fecha">
    <br>
    <br>
    <br>
    <input type="submit" id="open-datepicker" value="cambiar fecha">
    </body>
    </html>

1
  • Por favor no olvides marcar como aceptada aquella respuesta que te dió la solución al problema expuesto
    – user128299
    el 10 abr. 2020 a las 15:00

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.