function bangali() {
$(document).ready(function() {
$(".amtcollected").keyup(function() {
$(".amtcollected1").attr("disabled", true);
});
$(".amtcollected1").keyup(function() {
$(".amtcollected").attr("disabled", true);
});
});
}
bangali();
4 Answers
You should use .prop():
.prop('disabled', true);
Also, you can simplify and rewrite it like this:
$(document).ready(function() {
$('.amtcollected, .amtcollected1').keyup(function(event) {
$(event.currentTarget).prop('disabled', true);
});
});
Comments
jQuery 1.6+ use prop()
$('#id').on('event_name', function() {
$("input").prop('disabled', true); //Disable input
$("input").prop('disabled', false); //Enable input
})
jQuery 1.5 and below use attr()
$('#id').on('event_name', function() {
$("input").attr('disabled','disabled'); //Disable input
$("input").removeAttr('disabled'); //Enable input
})
NOTE: Do not use .removeProp() method to remove native properties such as checked, disabled, or selected. This will remove the property completely and, once removed, cannot be added again to element. Use .prop() to set these properties to false instead.
bangalifunction.readyis sufficient