Peter Magic
Peter Magic

Reputation: 27

Exception from the jQuery function

Variable a is always one out of #u-about, #u-projects, #u-contact, #u-follow.
How to make the function not animate a?

function bla(a) {$('#u-about, #u-projects, #u-contact, #u-follow').animate(...);

Upvotes: 1

Views: 40

Answers (2)

Daniel Imms
Daniel Imms

Reputation: 50149

Use the .not() selector to exclude a particular variable or selector from a jQuery object.

$('#u-about, #u-projects, #u-contact, #u-follow').not(a).animation

Upvotes: 1

Adil
Adil

Reputation: 148110

You can use not() and pass a to not to exclude the element you do not want.

function bla(a) {$('#u-about, #u-projects, #u-contact, #u-follow').not(a).animate(...

not()

Given a jQuery object that represents a set of DOM elements, the .not() method constructs a new jQuery object from a subset of the matching elements. The supplied selector is tested against each element; the elements that don't match the selector will be included in the result, Reference

Upvotes: 1

Related Questions