0
function bangali() {
    $(document).ready(function() {
        $(".amtcollected").keyup(function() {
            $(".amtcollected1").attr("disabled", true);
        });
        $(".amtcollected1").keyup(function() {
            $(".amtcollected").attr("disabled", true);
        });
    });
}
bangali();
Tasos K.
  • 7,669
  • 7
  • 38
  • 57
Ali Ahsan
  • 11
  • 3
  • Share your HTML and post a problem question describing your problem and also give proper title – Satpal May 20 '15 at 09:27
  • You don't need `bangali` function. `ready` is sufficient – Tushar May 20 '15 at 09:28
  • 3
    possible duplicate of [Disable/enable an input with jQuery?](http://stackoverflow.com/questions/1414365/disable-enable-an-input-with-jquery) – Liam May 20 '15 at 09:32

4 Answers4

2

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);
    });
});
roka
  • 1,627
  • 1
  • 15
  • 21
1

You don't pass a boolean value but the string "disabled"

.attr("disabled", "disabled");
A1rPun
  • 14,111
  • 6
  • 51
  • 79
1

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

Adam Michalski
  • 1,619
  • 14
  • 32
0

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.

Kurenai Kunai
  • 1,786
  • 2
  • 10
  • 22