jQuery find - 它返回的元素是什么顺序? [英] jQuery find - What order does it return elements in?

查看:78
本文介绍了jQuery find - 它返回的元素是什么顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用jQuery的 find 方法,它非常有用。

I have been using jQuery's find method and it's been very useful.

但是,我遇到了一个例子,其中 find 似乎是重复的东西,而不是返回顺序中的元素他们出现在文件中。 (我不确定是否应该这样做 - 我对此表示怀疑)。

However, I came across an example where the find seemed to be duplicating things and not returning elements in the order they appeared in the document. (I'm not sure if find is supposed to do this - I doubt it).

但是,它不应该在找到的元素中有重复并显示错误的顺序吗?

However, it shouldn't have duplicates in the elements it finds and show the wrong order, surely?

可以在此处找到完整示例: jsFiddle - 请注意span [9]和span [10]是错误的顺序和重复。

Full example can be found here: jsFiddle - Notice how span[9] and span[10] are in the wrong order and duplicated.

为什么会这样?

更新以便输出写入文档,请使用上面的新链接。

Updated so that output is written to document, please use new link above.

推荐答案

.find()按文档顺序返回元素。更多信息: http://docs.jquery.com/Release%3ajQuery_1.3.2

.find() returns elements in document order. More info here: http://docs.jquery.com/Release%3ajQuery_1.3.2

我认为异常与通配符选择器有关。那些必要吗?删除它们似乎解决了这个问题。

I think the anomaly has something to do with the wildcard selectors. Are those necessary? Removing them seems to resolve the issue.

这篇关于jQuery find - 它返回的元素是什么顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆