2

I have the following list

enter image description here

and I need to disable the radio button with a specific value how can I do that using JQuery

wala rawashdeh
  • 423
  • 5
  • 17

2 Answers2

3

If you are using jQuery >= 1.6:

var desiredValue = 10; // or whatever value you need to disable
$("input[type=radio][value=" + desiredValue + "]").prop("disabled",true);

& If you are using jQuery < 1.6 do this:

var desiredValue = 10; // or whatever value you need to disable
$("input[type=radio][value=" + desiredValue + "]").attr("disabled","disabled");
Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
  • I need to select the elements that are only inside the ul not all radio elements I have others with the same values also – wala rawashdeh Aug 14 '13 at 12:15
  • keep one class for all radio's inside ul and then check with value and then attr/prop disabled......... by this all the input type radio will be disabled if more then one has same value on same page. – Anup Aug 14 '13 at 12:54
3

Try the following:

$(":radio[value=15]").prop('disabled', 'disabled');

Edited 'attr' to 'prop' method, thanks Ashraf Bashir

UPDATE

If you want to use the jquery selector for the radio buttons only inside your 'ulTeams', use the following selector:

$("#ulTeams :radio[value=15]").prop('disabled', 'disabled');

see @ jsFiddle

chris vietor
  • 2,050
  • 1
  • 20
  • 29