jQuery .find() not returning expected elements when using multiple selectors in nested lists
I've looked through the documentation and I'm still confused about I'm maintaining legacy code that Quick question that's been bugging me - I'm having trouble with jQuery's `.find()` method in a nested list structure... I have a list of items where each item can contain another list of sub-items. My goal is to select all the sub-items that match a specific class, but I’m not getting the expected results. Here’s a simplified version of my HTML structure: ```html <ul class="main-list"> <li class="item"> <span class="label">Item 1</span> <ul class="sub-list"> <li class="sub-item highlight">Sub Item 1</li> <li class="sub-item">Sub Item 2</li> </ul> </li> <li class="item"> <span class="label">Item 2</span> <ul class="sub-list"> <li class="sub-item">Sub Item 3</li> <li class="sub-item highlight">Sub Item 4</li> </ul> </li> </ul> ``` I want to select all `.sub-item` elements that have the class `.highlight`. This is what I tried: ```javascript let highlightedItems = $('.main-list').find('.sub-item.highlight'); console.log(highlightedItems.length); ``` Unexpectedly, the console logs `0` even though there are elements that meet the criteria. I’ve verified that jQuery is included correctly and that I’m running this code after the DOM is fully loaded. I've also checked for typos in the class names, and they are correct. I tried using `$('.sub-item.highlight')` directly, and it works as expected, returning the correct number of elements. I’m curious why using `.find()` on the parent list doesn’t yield the expected results. Is there some specific behavior of jQuery’s `.find()` method I’m missing, or could it be an issue with how I’m structuring my selectors? Any insights would be greatly appreciated! For context: I'm using Javascript on Windows. I've been using Javascript for about a year now. I'm developing on macOS with Javascript. Thanks in advance! I'd really appreciate any guidance on this.