EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
تعيين اللغة الافتراضية
أسئلة PF - المنتدى

كيفية تعطيل زر مع 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 سأل 7 السنوات
1 إجابات

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, وفي 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
جوشوا وقال يجعل 7 السنوات