Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Mobile – Toggle enable and disable state of a radio button

I have a radio button that I would like to be able to enable and disable through jQuery Mobile.

Radio button code:

<input type="radio" disabled="disabled" value="option1" />

tried:

$('input[type="radio"]').removeAttr('disabled');

and

$('input[type="radio"]').attr('disabled', '');

Neither of which seem to be able to toggle the button to enabled.


1 Answers

<input type="radio" id="rdoToggle" value="option1" />
$("input[type='radio']").checkboxradio('enable');

Refer the documnentation , jQuery and jQuery Mobile are different in this action.

$('#rdoToggle').toggle(function() {
  $("input[type='radio']").checkboxradio('enable');
}, function() {
  $("input[type='radio']").checkboxradio('disable');
});
like image 116
Sameera Thilakasiri Avatar answered Jan 25 '26 05:01

Sameera Thilakasiri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!