En este fragmento de código vamos a aprender cómo el botón de bloqueo tras clic utilizando jQuery. Con la ayuda de este método podemos evitar hacer clic en el botón después de la presentación del modelo, etc.
jQuery Fragmento de código – Botón de bloqueo tras Haga clic con jQuery
jQuery / JavaScript
<script type="text/javascript">
$(document).ready(function(){
$("#btnSubmit").click(function(){
$("#btnSubmit").prop('disabled',true);
});
});
<!--JS function to display alert message-->
function dispAlert(){
alert("Button disabled.");
}
</script>
Código fuente HTML con jQuery / JavaScript
<!--jQuery - Disable Button After Click using jQuery.-->
<html>
<head>
<title>jQuery - Disable Button After Click using jQuery.</title>
<!--Example CSS-->
<link href="ExampleStyle.css" type="text/css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btnSubmit").click(function(){
$("#btnSubmit").prop('disabled',true);
});
});
<!--JS function to display alert message-->
function dispAlert(){
alert("Button disabled.");
}
</script>
</head>
<body>
<h1>jQuery - Disable Button After Click using jQuery.</h1>
<p><input type="button" value="Submit" id="btnSubmit" onclick='dispAlert()'/></p>
</body>
</html>
Resultado
clic for DEMO y rarr;