0

I want to execute the same code on two jQuery objects.

var a = $('.one_div');

.... more code ...

var b = $('.ban');

.... more code ...

a+b .hide('fast');

2 Answers 2

4

Use .add():

a.add(b).hide('fast');
Sign up to request clarification or add additional context in comments.

Comments

0

Another way

$('.one_div , .ban').hide('fast');

If you want to use the same logic on cached variables then .add() is the way to go.

Comments

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.