salmane
salmane

Reputation: 4847

jquery selector and Objects selection

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

Upvotes: 4

Views: 3515

Answers (3)

Michael Haren
Michael Haren

Reputation: 108376

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.

Upvotes: 2

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103155

You can use multiple selectors like this:

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

Upvotes: 0

Kamiel Wanrooij
Kamiel Wanrooij

Reputation: 12404

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.

Upvotes: 1

Related Questions