开发者

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 thi开发者_开发知识库s 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


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.


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.


You can use multiple selectors like this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜