Help in jquery selector

I am using jquery selector

$('input,select,textarea').not('table input').attr('disabled',true); 

here I will turn off all input, select and textarea elements. but I do not need to disable any control that is in the table. I did this using .not ('table input'), but I also need to specify select along with input control in the table.

I have select conrol in a table that I don't want to disable. what will be the selector for this.

+4
source share
3 answers
 $('input,select,textarea').not('table input').not('table select').attr('disabled',true); 
+2
source
 $('input,select,textarea').not('table input,table select').attr('disabled',true); 
+1
source

You can use something like:

 $('input,select,textarea').not('table input').not('table select').attr('disabled',true); 

Or shorter:

 $('input,select,textarea').not('table input,table select').attr('disabled',true); 

But you can also add a class to all inputs that need to be disabled, and just use:

 $('.toBeDisabled').attr('disabled',true); 

Or some of them will not be disabled:

 $('input,select,textarea').not('.notToBeDisabled').attr('disabled',true); 

Or if you want to include all form elements (also buttons), use:

 $(':input').not('table :input').attr('disabled',true); 
+1
source

All Articles