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

3 Answers 3

2

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.

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

2 Comments

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)
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
1

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.

Comments

0

You can use multiple selectors like this:

$(selector1, selector2, ..., selectorn).jqueryfunction();

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.