tags:

views:

18

answers:

1

OK, going rond in circles again - I'm sure the answer will be obvious. Just not to me :)

I can't seem to specify this as one target amongst a few targets for a function:

$(this, "elem1, elem2").doStuff()

I just want to doStuff() to a pair of elements, one of which is this. I can only get it to work if I explicitly name the elements, ie...

$("elem1, elem2, elem3").doStuff() 

...works fine. But I can't seem to get it to work if I want to include this in the list. I have to write one line just for this, and another for elem1 elem2 etc.

All help greatly appreciated. Thanks.

+3  A: 

If I understand you correctly, you can use add() to add this to the jQuery object:

$("#elem1, #elem2").add(this).doStuff();

Or in reverse:

$(this).add("#elem1, #elem2").doStuff();

or even:

$(this).add("#elem1").add("#elem2").doStuff();
cletus
Thanks a bunch - I knew it would be straightforward enough.
odavy