Setting DIV to displayif it contains a UL list that does not contains any LI items

I am designing a WordPress theme and have this problem : The sidebar has some DIV containers which all have one UL list. But one of these UL lists has no LI items. Now I want to hide the DIV container that has this UL list without LI items.

I was trying this, but it failed to work:

.wrapper > aside > div > div:not(h3 ul li) {display:none;}<br />

Example code:

<div class="wrapper">
  <aside class="sidebar" role="complementary">
    <div class="sidebar-widget">
      <div id="recent-comments-2" class="widget_recent_comments">
        <h3>Recent Comments</h3>
        <ul id="recentcomments"></ul>
      </div>
    </div>
  </aside>
</div>

Solutions

You can do it through PHP code or if you want a much simpler approach, then use jQuery. It would check that if the UL has li as its children with this function .hasChildren() . Thus it will turn it into display:block , otherwise display:none

Similar questions

error setting certificate verify locations: CAfile ca-bundle.crt CApath: none
I am trying to install the plugins directly from wordpress admin panel (instead of manual download and install). I am getting this error I am unable to get the root cause. Please provide the solution. Any help would be appreciated. Thank you, Mahesh
Hover text-decoration: none; does not work in IE
I read through the other similar posts but I still can't get the text-decoration: none to work in IE. It works in Edge, Chrome, and Firefox. The pages are also on WordPress (if it makes any difference). CSS I'm using: Any other ideas? I only want the text link to be underlined, I don't want my glyph to be underlined on hover.
Image Overlay Hover “pointer-events: none;” does not work in WordPress?
So someone gave me a good solution in making the overlay clickable, but it causes the overlay to expand vertically, breaking the overlay effect in WordPress (although it looks fine in codepen). I found another solution which was to add pointer-events: none; which allowed the overlay to be clickable, taking you to another url. I tried implementing i...
what does <a class="none"> really mean?
Im not sure if anyone can help me with this but I came across this piece of code while modifying a theme for a wordpress. What is the effect of class="none" in this ? There is no css pointing to this class anywhere. Thanks in advance.
Unwanted "Expand" link won't go away. Can't trace source. display:none; not working. (Wordpress)
As seen on any product at alcapparel.com: http://www.alcapparel.com/shop/clothing/looter-crop-tee/ As you can see the word "Expand" is located in the upper left of the product image. I've reinstalled the YITH WooCommerce Magnifier plugin, they reportedly patched it two days ago, and I can't find the source of the word anywhere in the files. I've al...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .