Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I exclude a class from my jQuery selector?

Tags:

jquery

I have the following code:

$(":input[type='text']").wijtextbox();

What I would like is for the wijtextbox() NOT to be applied if the class of my textbox is native. Is there a way I can somehow exclude this by adding to the above selector?

Make this a wijtextbox:

<textarea class="wijmo-wijtextbox ui-widget ui-state-default ui-corner-all valid" >xx</textarea>

Don't make this a wijtextbox:

<textarea class="native wijmo-wijtextbox ui-widget ui-state-default ui-corner-all valid" >xx</textarea>
like image 461
Jessica Avatar asked Feb 15 '12 03:02

Jessica


2 Answers

This:

$("input[type='text']").not(".native").wijtextbox();

or this:

$("input[type='text']:not('.native')").wijtextbox();

should do the trick. There's also a shortcut for selecting an input whose type is text:

$("input:text").not(".native").wijtextbox();

More on not() here.

EDIT: Since it appears you need to select a textarea, try the following:

$("textarea").not(".native").wijtextbox();
like image 90
Purag Avatar answered Oct 24 '22 17:10

Purag


Try this.

$(":input:not(.native)").wijtextbox();

Since you selecting textarea you can even use this

$("textarea:not(.native)").wijtextbox();

:not(selector) - Selects all elements that do not match the given selector.

like image 42
ShankarSangoli Avatar answered Oct 24 '22 18:10

ShankarSangoli