开发者

disabling radio buttons by name attribute with jquery

开发者 https://www.devze.com 2023-01-16 10:33 出处:网络
say I have a bunch of radio buttons in an html form.How do I find and disable all 开发者_如何学Pythonradio input types with a given name=\"?\" value (where ? can be anything I specify)?It is simple:

say I have a bunch of radio buttons in an html form. How do I find and disable all 开发者_如何学Pythonradio input types with a given name="?" value (where ? can be anything I specify)?


It is simple:

$('input[name="name_here"]').attr('disabled', 'disabled');

Replace name_here with the name of your radio buttons.

And you can enable it back from code using:

$('input[name="name_here"]').removeAttr('disabled'');


var name = 'someName';
$('#myForm').find(':radio[name=' + name + ']').attr('disabled', 'disabled');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号