My page creates multiple buttons as id = \'rbutton_\"+i+\"\'
. Below is my code:
For Jquery UI buttons this works :
$("#buttonId").button( "option", "disabled", true | false );
Try this
function disable(i){
$("#rbutton_"+i).attr("disabled",true);
}
Here's how you do it with ajax.
$("#updatebtn").click(function () {
$("#updatebtn").prop("disabled", true);
urlToHandler = 'update.ashx';
jsonData = data;
$.ajax({
url: urlToHandler,
data: jsonData,
dataType: 'json',
type: 'POST',
contentType: 'application/json',
success: function (data) {
$("#lbl").html(data.response);
$("#updatebtn").prop("disabled", false);
//setAutocompleteData(data.response);
},
error: function (data, status, jqXHR) {
alert('There was an error.');
$("#updatebtn").prop("disabled", false);
}
}); // end $.ajax
disable button:
$('#button_id').attr('disabled','disabled');
enable button:
$('#button_id').removeAttr('disabled');
This works for me:
<script type="text/javascript">
function change(){
document.getElementById("submit").disabled = false;
}
</script>
I want to disable button on some condition, i am using 1st solution but it won't work for me. But when I use 2nd one it worked.Below are outputs from browser console.
1. $('#psl2 .btn-continue').prop("disabled", true)
<a class="btn btn-yellow btn-continue" href="#">Next</a>
2. $('#psl2 .btn-continue').attr("disabled","disabled")
<a class="btn btn-yellow btn-continue" href="#" disabled="disabled">Next</a>