Sajeev C
Sajeev C

Reputation: 1538

Not able to remove disable property of button using jQuery

I have a set of check-boxes only one of them will be checked at a time. (I need check-boxes here not radio buttons). There is a disabled button in the same page.

I am trying to remove the disabled property of button upon clicking a checkbox.

Unfortunately, it didn't work.

HTML

<input type="checkbox" name="group2[]" class="me" data-btname="xxxx" />
<input type="checkbox" name="group2[]" class="me" data-btname="xxxx" />
<input type="checkbox" name="group2[]" class="me" data-btname="xxxx" />

<input type="button" name="aa" id="xxxx" value="this is me" disabled />

jQuery

$('.me').on('change', function() {
    $('input[name="' + this.name + '"]').not(this).prop('checked', false);
    var buton_namee = $(this).attr('data-btname');
    //alert(buton_namee);
    $('#buton_namee').removeAttr('disabled');
});

Fiddle

Upvotes: 0

Views: 68

Answers (1)

Rick Su
Rick Su

Reputation: 16440

You are retrieving id from data-btname, so to put it in a selector like below

$('#' + buton_namee).removeAttr('disabled');

Upvotes: 3

Related Questions