Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS jQuery .find() method in JS Re: jQuery .find() method in JS

#143219
pixelgrid
Participant

looking at the jquery source you can see that

jQuery.find = Sizzle;

where sizzle is the way jquery handles dom traversing

what you have in jQuery(‘selector1’).find(‘selector2’) is two dom traversals one applied to one element(might be document or a selected element) and the second applied to its children.

simple example

to get div.two in jquery with find

jQuery(‘.one’).find(‘.two’);

with plain js you can do

document.querySelector(‘.one’).querySelector(‘.two’)