Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 哪个最快?查找()或标准_Jquery - Fatal编程技术网

Jquery 哪个最快?查找()或标准

Jquery 哪个最快?查找()或标准,jquery,Jquery,我只是想知道,我现在已经开始在jQuery中缓存DOM对象了。例如,假设这是我的文档: <div class="test"> <a href="#">Test</a> </div> 然而,现在我正在做这件事,我想知道选择缓存对象的子对象的最佳方法是什么 $('a', $test) // the standard method, only searching the cached object $test.find('a') // usin

我只是想知道,我现在已经开始在jQuery中缓存DOM对象了。例如,假设这是我的文档:

<div class="test">
    <a href="#">Test</a>
</div>
然而,现在我正在做这件事,我想知道选择缓存对象的子对象的最佳方法是什么

$('a', $test) // the standard method, only searching the cached object
$test.find('a') // using find() on the cached object
这两种方法一下子就浮现在我的脑海里,什么方法最快?最好的方法是什么

提前谢谢。

它们完全一样

在内部,选择器上下文是通过
.find()
方法实现的,因此
$(“span”,this)
相当于
$(this).find(“span”)


第一种方法使用内存中的第二种方法。好的,谢谢。我不知道为什么我被否决了,但是谢谢你的回答。可能是因为你也可以自己阅读文档。
$('a', $test) // the standard method, only searching the cached object
$test.find('a') // using find() on the cached object