Hiding an element that contains only spaces using CSS

前端 未结 9 532
不思量自难忘°
不思量自难忘° 2021-01-07 17:34

I am trying to hide the following element in an automatically generated HTML document:

  

9条回答
  •  既然无缘
    2021-01-07 18:03

    I don't think you can do it with pure CSS.

    However with a little JavaScript you can do it.

    var allParas = document.getElementsByTagName('p');
    //filter by class name if desired...
    for(var i=0;i

    If you have access to jQuery it is a little easier to do the filtering with their built in selectors.

    $('p.sitspagedesc').each(function(){
      if($(this).children().length == 0){
        $(this).hide();
      }
    });
    

提交回复
热议问题