title: Hiding List View web parts when they are empty (SharePoint)
body: <p>Searching on Google, I found this code. I need to include this script in my page to hide empty Lists. How can I do this?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;  
  function HideEmptyWebParts()  
  {  
  var itemsfound = new Array;  
  var elements = document.getElementsByTagName('*');  
  for(var i=0;i&lt;elements.length;i++)  
  {  
    if(elements[i].className == 'ms-vb')  
    {  
       itemsfound.push(elements[i]);  
    }  
  }  
  
  for (var i=0;i&lt;itemsfound.length;i++)  
  {  
      if (itemsfound[i].innerHTML.indexOf("There are no items to show in this view of the")&gt;-1)  
      {  
              itemsfound[i].parentNode.parentNode.parentNode.parentNode.innerHTML="&lt;div class='ms-      vb'&gt;Not enough data to produce a dashboard.&lt;/div&gt;";  
  
        }  
    }  
  }  
  
  _spBodyOnLoadFunctionNames.push("HideEmptyWebParts")  
  
  &lt;/script&gt;  
  </code></pre>