简体   繁体   English

使用JQuery根据值在列表内选择输入

[英]select input inside list based on value using JQuery

I have the following list 我有以下清单

在此处输入图片说明

and I need to disable the radio button with a specific value how can I do that using JQuery 并且我需要禁用具有特定值的单选按钮,如何使用JQuery做到这一点

If you are using jQuery >= 1.6: 如果您使用的是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: &如果您使用的是jQuery <1.6,请执行以下操作:

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

Try the following: 请尝试以下操作:

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

Edited 'attr' to 'prop' method, thanks Ashraf Bashir 感谢Ashraf Bashir,将“ attr”编辑为“ prop”方法

UPDATE UPDATE

If you want to use the jquery selector for the radio buttons only inside your 'ulTeams', use the following selector: 如果只想在“ ulTeams”内部为单选按钮使用jquery选择器,请使用以下选择器:

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

see @ jsFiddle 看到@ jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM