Reputation: 11
function bangali() {
$(document).ready(function() {
$(".amtcollected").keyup(function() {
$(".amtcollected1").attr("disabled", true);
});
$(".amtcollected1").keyup(function() {
$(".amtcollected").attr("disabled", true);
});
});
}
bangali();
Upvotes: 0
Views: 117
Reputation: 1902
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.
Upvotes: 0
Reputation: 1792
find row index by
var row_index = $(this).parent('table').index();
and set disabled
$("table").eq(row_index).disabled = true;
I didn't test it
Upvotes: 1
Reputation: 1687
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);
});
});
Upvotes: 2
Reputation: 16847
You don't pass a boolean value but the string "disabled"
.attr("disabled", "disabled");
Upvotes: 1