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

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46455
    Anonymous
    Inactive

    I need jQuery .find() method in JS, without using jQuery library . . .

    #143197
    TheDoc
    Member

    This is likely the closest for my limited JS knowledge: https://developer.mozilla.org/en-US/docs/Web/API/document.getElementById

    #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’)

    #143236
    Anonymous
    Inactive

    Thank’s for answers, all done ;)

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.