1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. </head>
    6. <body>
    7. <div class="box">
    8. <div>adsfasdf</div>
    9. <p>sfasdf</p>
    10. <span>asdfa</span>
    11. <div>
    12. <span class="aa">nihao</span>
    13. </div>
    14. </div>
    15. <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    16. <script>
    17. var $box = $('.box');
    18. // span是元素选择器, 也可以换成其他的选择器, 比如id,class
    19. var $aa = $box.find('.aa')
    20. console.log($aa);
    21. // 查找$box所有后代元素
    22. var $souyou = $box.children()
    23. console.log($souyou);
    24. </script>
    25. </body>
    26. </html>