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');
精彩评论