views:

173

answers:

4

typically when you refer to an object you would use a selector like this :

$(this).jqueryfunction()

if u would need an element within this object you would use :

$('typicalselector',this).jqueryfunction()

My question is how would I use jquery selector to select various objects something along the lines of :

($(this.fistobject) and $(this.secondObject)).jqueryfunction() 

thanks for your help

+1  A: 

You can use a comma, just like in CSS. I.e.

$('div, a', this)

would select all div and a elements in 'this'.

I dont think you can work jQuery on Javascript objects, they should be jQuery-wrapped HTML Elements.

Kamiel Wanrooij
A: 

Have a look at the add method.

kgiannakakis
A: 

You can use multiple selectors like this:

$(selector1, selector2, ..., selectorn).jqueryfunction();
Vincent Ramdhanie
A: 

When you wrap an object or run a selector, you get a set or collection. So this would return a collection and then add another collection to it, and then perform jqueryfunction() to the combined set:

$('someSelector').add('anotherSelector').jqueryfunction()

This works with contexts, too.

Michael Haren
This works . is there a way to do it in the same selector like this :$(this.one and this.otherone).jqueryfunction() ? (this.one and this.otherone are both javascript objects by the way)
salmane
What kind of JS objects? Post some more code. If they can be wrapped with a $(), then you can do this: `$(obj1).add(obj2).jqueryfunction` or if that doesn't work, then this should: `$(obj1).add($(obj2)).jqueryfunction`
Michael Haren