Hide button with JQuery function

1

How do I pass this to jQuery

id="btn_submit" onclick="javascript:document.getElementById('btn_submit').style.visibility = 'hidden';

Is to temporarily hide or block a button to avoid double submission of a form, is there any other way to avoid it?

    
asked by WilsonicX 17.07.2018 в 22:26
source

2 answers

1

Basically by clicking the id btn_submit  changes the CSS visibility property to hidden

A time of 2 seconds is added with setTimeout ()

  $("#btn_submit").on('click',function(){ //Evento Click
     $("#btn_submit").css('visibility', 'hidden'); //Cambio de propiedad CSS
     setTimeout(function(){ //Se aguardan los milisegundos marcados en la próxima linea
       $("#btn_submit").css('visibility', 'visible');
     }, 2000); //2000 milisegundos == 2 segundos
   });

Here is more about setTimeout link

    
answered by 17.07.2018 / 22:35
source
1

I did not understand well the double submit but here I leave you a code to do what you want with jquery:

$("#btn_submit").click(function(){ //le decimos cuando hagas click ejecute una funccion anonima

  $(this).hide(); //y que oculte este elemento clickeado

 $(this).css("visivility","0"); //o si quieres darle simplemente una visivilidad 0 seria asi
})
    
answered by 17.07.2018 в 22:33