What is the difference direct descendent (>) vs. descendant in jQuery selectors?

后端 未结 7 573
感情败类
感情败类 2021-02-04 03:53

What\'s the difference between these two jQuery statements? They seem to do the same thing by getting all the children div tags.

$(\"#mainblock div\")

7条回答
  •  心在旅途
    2021-02-04 04:13

    Have a look at jQuery Selectors

    Child Selector ("parent > child") - Hierarchy Selects all direct child elements specified by "child" of elements specified by "parent".

    Descendant Selector ("ancestor descendant")- Hierarchy Selects all elements that are descendants of a given ancestor.

提交回复
热议问题