I am relatively new to working with JS and HTML. I have attempted to use the following function, but unfortunately, I am not seeing any results. Any assistance would be greatly appreciated. Below is the JavaScript code as well as the HTML div and table where it should be implemented.
function emptyTableRedisplay(table, uRowsMin)
{
if (! table || ! table.rows || table.rows.length >= uRowsMin)
return;
let styleHide = table.getAttribute("data-hide-style");
if (! styleHide || styleHide === "")
return;
let idAlt = table.getAttribute("data-alt-id");
if (! idAlt || idAlt === "")
return;
# find the enclosing div
let el = table.parentNode;
while (el && el.tagName.toLowerCase() == "div")
el = el.parentNode;
if (! el)
return;
var alt = el.parentNode.parentNode.getElementById(idAlt);
if (! alt)
return;
el.classList.add(styleHide);
alt.classList.remove(styleHide);
}
This is what I included in the HTML:
<div id='emptyTableRedisplay'>
<h3>Header</h3>
<p>Notes</p>
<table class='data-table monetary' data-final-rows-to-not-sort='0' data-hide-style='1' data-alt-id='2'>
<tbody>
<tr>
<th class='sortable-col' data-collation-form='0-9'>Box #</th>
<th class='sortable-col'>Box Name</th>
<th class='sortable-col' data-collation-form='0-9'>Reported</th>
</tr>
</tbody>
</table>