【问题标题】:jQuery: are these all statements true for find() method?jQuery:对于 find() 方法,这些语句都是真的吗?
【发布时间】:2015-01-29 19:19:39
【问题描述】:

我很好奇以下所有陈述是否都相同:

$(".postcell div").find(".post-taglist")
$(".postcell").find("div").find(".post-taglist")
$(".postcell").find("div .post-taglist")

如果它对链中任意数量的.find、任何类、ID 等都有效。

我问的原因是确保当我将选择器替换为(变量 + 选择器的其余部分)时不会遗漏任何内容。

【问题讨论】:

标签: javascript jquery find selector chaining


【解决方案1】:

是的,所有这些语句都应该返回相同的内容。

$(".postcell").find("div").find(".post-taglist") 会比其他两个稍慢。

【讨论】:

    猜你喜欢
    • 2016-02-20
    • 1970-01-01
    • 2015-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多