EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
PF Preguntas - Foro

¿Cómo deshabilitar un botón con jQuery?

Tengo un botón en HTML, y me gustaría que para evitar dobles clicks, una vez que el usuario lo pulse, éste se deshabilite.

¿Alguna aportación?

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
lovim79 preguntó hace 7 años
1 Respuestas

Para deshabilitar un botón en jQuery hazlo de la siguiente forma:

jQuery('#idboton').prop('disabled', true);

Para hacer lo que quieres, crea una función donde deshabilites el botón, y en el onkeyup del botón llámala

<input type="button" name="boton" id="idboton" onkeyup="mi_funcion()" value="Púlsame" />

<script type="text/javascript">
function mi_funcion() {
jQuery('#idboton').prop('disabled', true);
}
</script>
Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
Joshua respondió hace 7 años