Some idea of how to submit the button using javascript or jquery

2

Here I send the data but I have to press the button and I want to do it can also be done by pressing enter:

<input type="text" name="fecha" id="fecha">
<input type="text" name="direccion" id="direccion">
<div id="enviar">Enviar</div>

here they are received in jquery:

 $("#enviar").click(function(){

    fecha =$("#fecha").val();
    direccion =$("#direccion").val();


    });
    
asked by Alberto Julio Arce Escolar 13.07.2018 в 04:56
source

1 answer

3
   $(document).bind('keypress', function(e) {
    if(e.keyCode==13){
        $('#enviar').trigger('click');
    }
});

 $("#enviar").click(function(){
    fecha =$("#fecha").val();
    direccion =$("#direccion").val();


});
    
answered by 13.07.2018 / 06:08
source