I want to write a selector which will select
1. Input elements of type radio OR checkbox
2. Which are selected ie. wich have is(':checked') as true
3. and have a some class applied to it.
I come up with following code
$([':radio'],[':checkbox']).each(function() {
if($(this).is(':checked'))
{
className = $(this).attr('class');
if(className!= "")
{
$('#'+className +' :input').attr('disabled', false);
}
}
});
Its workign fine but I am looking more efficient solution as I am selecting all radio and checkbox and filtering over it.
How can I combine all conditions ?
Thanks!
EDIT:
The radio or checkbox can have ANY class ie I want to select all radio or checkboxes which are selected and have atleast one class applied it.