简体   繁体   中英

Hide div is child is empty

The URL to the page is this .

And the screenshot to the questioned area is this .

I want, if the accordion has no content, then hide the accordion title itself. Empty accordion elements won't show.

I have used this script for that:

jQuery(".su-spoiler-content:empty").parent().hide(); 

But I can't find it doing anything.

Is there anything wrong in the above code?

It seems that you have "invisible stuff" inside your div.

在此处输入图片说明

I just edit as HTML in the browser and it works

在此处输入图片说明 在此处输入图片说明

try that...

document.querySelectorAll('div.su-spoiler-content').forEach(xDiv=>
  {
  if (xDiv.innerText.trim() === '')
      xDiv.closest('div.su-spoiler').style.display = 'none'
  })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM