Good day pro. Tell me, I now use the function "hide table" by clicking on the link. Where I insert id="hide_this" - the element (table) disappears.

The question is, how do I do the opposite

  • first the table is hidden,
  • And when you click on the link, it appears?

Code:

 function toggle() { if( document.getElementById("hidethis").style.display=='none' ){ document.getElementById("hidethis").style.display = ''; }else{ document.getElementById("hidethis").style.display = 'none'; } } 

Link:

 <a href="#null" toggle() onclick="toggle()">Показать отделы:</a> 

The fact that we hide:

 <table id="hidethis"> 

    2 answers 2

    Add initially to html for tables style = "display: none" . In this case, the elements will initially be hidden.

     <table style="display:none" id="hidethis"> 
    • you are a genius ... :) - Oleg Zolotarenko
     <table id=myTable class=hidden>...</table> <a href="javascript:toggle();">toggle table</a> .hidden{display:none; } function toggle() { document.getElementById('myTable').classList.toggle('hidden'); }