Arsenii
Arsenii

Reputation: 784

jQuery: how to exclude IDs from .find()?

I have this code:

$("#someform").find("input:not[#myid]").change(function() {
....
});

But the code is not working.

The task: I need to select all the inputs, but exclude one with ID="myid".

Your help is highly appreciated!

Upvotes: 0

Views: 1332

Answers (2)

Pranav C Balan
Pranav C Balan

Reputation: 115242

Syntax of :not() is not correct ,

$("#someform").find("input:not(#myid)").change(function() {
   //                       --^-- --^--
   ....
});

Or you can use not()

$("#someform").find("input").not("#myid").change(function() {
   ....
});

Upvotes: 1

AmmarCSE
AmmarCSE

Reputation: 30607

Close, use parenthesis instead of square brackets

$("#someform").find("input:not(#myid)").change(function() {
....
});

See :not()

Upvotes: 4

Related Questions