Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing multiple values to :not() jQuery?

Tags:

jquery

I want to filter multiple values from an event in jQuery.

At the moment I have:

.filter(":not(.element)")

How would I go about adding more things to filter? I've tried:

.filter(":not(.element, .another, .etc)")

and

.filter(":not(.element)").filter(":not(.another)").filter(":not(.etc)")

and

.filter(":not(.element),:not(.another),:not(.etc)")

With no luck. What do I need to do?

Thanks.

EDIT: Thanks for the answers - I've find another solution to my problem that avoids having to do what I've asked in the question, but evidently I wasn't doing something properly in my code since the solutions posted work. I will mark an answer as correct, many thanks.

like image 702
Anonymous Avatar asked Dec 06 '22 14:12

Anonymous


2 Answers

It is working, you just need to separate each element using a comma (,) in the :not() selector.

You can check the example here: http://jsfiddle.net/LVUMs/

like image 194
Vishal Avatar answered Dec 27 '22 17:12

Vishal


Looks like it is working. http://jsbin.com/uyayot/edit#javascript,html

I tried:

$('div').not('#div2,#div4').each ( function () {
    alert ( $(this).attr ('id' ) );
  });
like image 30
Rakesh Juyal Avatar answered Dec 27 '22 18:12

Rakesh Juyal