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 preguntó 我们的一日三餐 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 年