if div has content show div

前端 未结 5 1088
再見小時候
再見小時候 2020-12-14 06:44

ok heres what i have... it works fine but it looks for a word rather than content. i just want it to show when there is any content..

 $(document).ready(func         


        
5条回答
  •  别那么骄傲
    2020-12-14 07:09

    If you want to check for text, you can use the text() method:

     $(document).ready(function(){
       if ($("#box3").text().length > 0) {
         $('#third').show();
       }                                           
     });
    

    Or for html:

     $(document).ready(function(){
       if ($("#box3").html().length > 0) {
         $('#third').show();
       }                                           
     });
    

提交回复
热议问题