The task is to hide the div if there is no content in it. As soon as the content appears in it, the div should immediately appear on the site. Prompt solutions to this problem. There are guesses that have to do with JS. But I still can not imagine how.

    2 answers 2

    For example, so js :

    if($('.block').text() == ' '){ $('.block').css({'display': 'none'}); } else { $('.block').css({'display': 'block'}); } 
     <p class="block"></p> <p class="block">Если есть текст, то блок виден</p> 

    Or so css :

     block:empty { display: none; } 
     <p class="block"></p> <p class="block">Если есть текст, то блок виден</p> 

      The answer is on this link (using jQuery):

       if ($('#element').is(':empty')){ //do something } 

      You can also use pure CSS :

       div:empty { display: none }