0
function bangali() {
    $(document).ready(function() {
        $(".amtcollected").keyup(function() {
            $(".amtcollected1").attr("disabled", true);
        });
        $(".amtcollected1").keyup(function() {
            $(".amtcollected").attr("disabled", true);
        });
    });
}
bangali();
3
  • Share your HTML and post a problem question describing your problem and also give proper title Commented May 20, 2015 at 9:27
  • You don't need bangali function. ready is sufficient Commented May 20, 2015 at 9:28
  • 3
    possible duplicate of Disable/enable an input with jQuery? Commented May 20, 2015 at 9:32

4 Answers 4

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);
    });
});
Sign up to request clarification or add additional context in comments.

Comments

1

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

.attr("disabled", "disabled");

2 Comments

either that or use prop("disabled", true);
Really you should use prop for disabled as it's a property not an attribute though in reality both will work.
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

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.