I've done a few things such as selecting all children of an element, all parents of an element, first child etc.. but this is a little tricky.
I have the structure somewhat similar to this:
<div class="body">
    <a href="something">Something</a>
    <small>
          <a href="something-else开发者_运维技巧">Something-else</a>
    </small>
</div>
and this structure is repeated a whole lotta times.
I need to select all <a> elements found only in the top level div.body and ignore all <a> that's found in the <small> element.
How do I go around with this please?
thanks,.
Simply use the child selector rather than the descendant selector:
$('div.body > a');
The child selector only selection direct elements of a parent element, so:
$('div.body > a')
should do the trick
Use the child selector:
$("div.body > a")
A > B means: "B is a immediate child of A", whereas
A B means: `B is a (not strictly immediate) child of A.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论