Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
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?

code:

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

<script>
    var tbl = document.getElementById("table-example");
    if (tbl.rows.length == 1) {
        console.log("IT WORKED");
        tab_header = document.getElementById("tab_header").innerHTML = "";
    }
    console.log(tbl.rows.length);
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can hide whole table, if is empty:

let table = document.querySelector('.table-example');
table.style.display = 'none';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!