Hide PDF Table If It Has Only One Header Row And No Data

In this guide, we will share an example of JavaScript to hide the table if it only has 1 header row.

<!-- Add jQuery -->
<script type="text/javascript"  src="https://cdn.formyoula.com/vendor/jquery/jquery-2.1.3.min.js"></script>

<!-- Hide if the table has only 1 header row -->
<script type="text/javascript">

// Find all PDF tables
$( 'table' ).each( function( index ) {
  // Check if the table has only 1 header row
  if ( $( this ).find( 'tr' ).length == 1 ) {
    // Hide table
    $( this ).hide();
  }
} );

</script>
image

For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂