If parent element contains certain child element
Hi.
I'm trying to hide sertain elements
<button class="sidebar__categories-toggle">></button> only in those divs that do not have child elements <ul class="sidebar__categories-list"> .
So if category has subcategories then I need this sign
<button class="sidebar__categories-toggle">></button>, but if not - then I need to hide it
Tried
- (function(jQuery) {
- jQuery(document).ready(function() {
- if (jQuery('li.sidebar__categories-item').find('ul.sidebar__categories-list').length !== 0) {
jQuery('button.sidebar__categories-toggle').hide();
}
});
- })(jQuery);
But it hides all of
<button class="sidebar__categories-toggle">></button>
What am I doing wrong?
Thanks.