开发者

disabling radio buttons by name attribute with jquery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜