yoyo
yoyo

Reputation: 1133

How to select forms except those under div #target in jQuery?

$('form') is selecting too many for me,

how to restrict it so that those not under #target are selected?

Upvotes: 0

Views: 185

Answers (2)

Felix Kling
Felix Kling

Reputation: 816384

The :not selector is the one to use, however it might not be apparent with selector to pass to :not.

Train of thoughts: form will select all forms. You don't want to select the forms that are under the node with ID parent. Hence, these forms are selected by #parent form.

The complete selector would be:

$("form:not(#parent form)")

I concur with the other comments. The jQuery API reference is quite good and will give you the answer faster than asking here. The more you use it, the more you become familiar with it and you will find information more efficiently. Moreover, it will give you a better picture of how jQuery methods are structured and which ones are related.

Upvotes: 2

Abdel Raoof Olakara
Abdel Raoof Olakara

Reputation: 19353

You can use the not selector! Refer the jQuery guide!

Upvotes: 1

Related Questions