Selecting only first-level elements in jquery

前端 未结 10 2190
忘了有多久
忘了有多久 2020-11-28 03:14

How can I select the link elements of only the parent

    from a list like this?

    • Link
10条回答
  •  执念已碎
    2020-11-28 04:03

    You might want to try this if results still flows down to children, in many cases JQuery will still apply to children.

    $("ul.rootlist > li > a")
    

    Using this method: E > F Matches any F element that is a child of an element E.

    Tells JQuery to look only for explicit children. http://www.w3.org/TR/CSS2/selector.html

提交回复
热议问题