Naor
Naor

Reputation: 24093

jquery shortcut

This is not so importent question, I just wonder if this is possible.
I would like to do somethinf like this:

$elem.find('#a').click(...);
$elem.find('#b').click(...);
$elem.find('#c').click(...);

I one sentence like:

$elem
    .find('#a').click(...)
    .find('#b').click(...)
    .find('#c').click(...);

Is something like that possible?

I am asking about the find method/functionality only!

Upvotes: 0

Views: 155

Answers (3)

egze
egze

Reputation: 3236

I believe it's

$elem
    .find('#a').click(...).end()
    .find('#b').click(...).end()
    .find('#c').click(...);

Upvotes: 1

Alex Dn
Alex Dn

Reputation: 5553

You can do something like: $elem.find('#a,#b,#c').click(...);

Upvotes: 0

Andy E
Andy E

Reputation: 344705

You can use end():

$elem
    .find('#a').click(...).end()
    .find('#b').click(...).end()
    .find('#c').click(...).end();

Upvotes: 2

Related Questions