1

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(...);

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

It doesn't work. While "a='#u-about'" "function bla(a) {$('#u-about, #u-projects, #u-contact, #u-follow').not(a).animate(" does nothing, but "function bla(a) {$('#u-projects, #u-contact, #u-follow').animate(" works.
jsfiddle.net/943L3 But I guess it won't work due to inability to upload images.
1

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

1 Comment

I think that a refers to an object, not to the anchor tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.