jquery选择器和对象选择

时间:2010-01-04 13:18:28

标签: jquery-selectors

通常当你引用一个对象时,你会使用这样的选择器:

$(this).jqueryfunction()

如果您需要此对象中的元素,您将使用:

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

我的问题是如何使用jquery选择器来选择各种对象:

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

感谢您的帮助

3 个答案:

答案 0 :(得分:2)

当您包装对象或运行选择器时,您将获得一个集合或集合。所以这将返回一个集合,然后再add另一个集合,然后对组合集执行jqueryfunction():

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

这也适用于上下文。

答案 1 :(得分:1)

您可以使用逗号,就像在CSS中一样。即。

$('div, a', this)

会选择'this'中的所有div和元素。

我不认为你可以在Javascript对象上运行jQuery,它们应该是jQuery包装的HTML元素。

答案 2 :(得分:0)

你可以使用这样的多个选择器:

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