tags:

views:

37

answers:

3

hello,

How can I exclude a certain input box from adding an element?

$('div#tabs input[type="text"], select option:selected, input:checked, textarea').addClass('takethis');

I wnat this for all input boxes and select boxes except for on certain input box. How would i do this?

+1  A: 

You could use Traversing/not or Selectors/not:

$('div#tabs input[type="text"],
   select option:selected,
   input:checked, textarea').not('#elementToExclude').addClass('takethis');
CMS
A: 

Two methods:

CSS selector method

First, give your special input an id:

<input id="excluded-input" />

Then, use the :not CSS selector to exclude it:

$('[...], input:not(#excluded-input), [...]).addClass('takethis');

Traversal method

Use the .not() function instead:

$('div#tabs input[type="text"], select option:selected, input:checked, textarea').not('#excluded-input').addClass('takethis');

Ron DeVera
A: 

Thanks for the answer. I liked Romn's second answer and CMS answer which are both the same.

Thanks!

sanders