jquery child selector without parent

前端 未结 3 1894
旧巷少年郎
旧巷少年郎 2021-02-14 05:38

I was looking at some code from a tutorial for creating a carousel menu and noticed parent child selectors without the parent. Never seen this before, and confused to what it is

3条回答
  •  悲哀的现实
    2021-02-14 06:19

    This selector with a context:

    $('> div', this)
    

    gets flipped around to use a .find() like this:

    $(this).find('> div')
    

    which with the > child-selector is just:

    $(this).children('div')
    

    The others are doing the same deal, they could use .children(), and actually it'd be more efficient to do so.

提交回复
热议问题