Remove css class of element

(Django) I have a table that I am attempting to hide if it is empty. I have mostly achieved this the only issue is that the CSS styling is still present after “removing” the table.

How do I remove all of the CSS styling for a particular element?


<table class="post-table" id="table-example">
        <th class="table-header" colspan="1" id="tab_header">
            <h3>ADDITIONAL INFO</h3>
    <tbody id="tab_body">
        {% if post.additional_info != '' %}
            <td id="test">{{ post.additional_info }}</td>
        {% endif %}

    var tbl = document.getElementById("table-example");
    if (tbl.rows.length == 1) {
        console.log("IT WORKED");
        tab_header = document.getElementById("tab_header").innerHTML = "";


You can hide whole table, if is empty:

let table = document.querySelector('.table-example'); = 'none';

Source: stackoverflow