0

I want to disable input id of buttons in java script. My code:

var uniqid = "idModify_" + index;
var buttonModify = $('<input type="button"/>');
buttonModify.attr('id', uniqid);
li.append(buttonModify);
buttonModify.button();
if (my required condition is true)) {
    $("#uniqid").attr("disabled", "disabled").addClass("disabled");
}

I have tried $(uniqid ).prop('disabled', true); it does not work.

Note: index value will be 0 to n every time the button gets added to li.

2
  • Try $("#"+uniqid).attr("disab... Commented Nov 27, 2015 at 12:25
  • Got it! thanks! @freedomn-m Commented Nov 27, 2015 at 12:31

1 Answer 1

1

You need to create ID selector using the variable uniqid

$("#" + uniqid).prop("disabled", true).addClass("disabled");

Better to use already referenced object

buttonModify.prop("disabled", true).addClass("disabled");
Sign up to request clarification or add additional context in comments.

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.