I want to show the the table "trackdata" and hide "notrackdata" table whenever I click the button. As of now the table "notrackdata" hides but "trackdata" doesn't show.
HTML
<button class="far fa-file-audio fa-3x" id = "audiotrack" onclick = "searchtrack()"></button>
<table style = "width:90%" class = "notrackdata" id = "notrackdata"> //NOTRACKDATA
<tr>
<th>NO TRACK DATA TO SHOW<br><img class = "fas fa-sad-tear fa-2x" id ="tear"></th>
</tr>
</table>
<table style = "width:90%" class = "trackdata" id ="trackdata"> //TRACKDATA
<th >
<tr class = "trackrow">
<td>Album Cover</td>
<td>Album Title</td>
<td>Artist</td>
<td>Track Preview</td>
</tr>
</th>
<tbody>
<tr>
<td><img src ="https:\/\/e-cdns-images.dzcdn.net\/images\/artist\/72f073a5829b368025b49c460b4b1918\/250x250-000000-80-0-0.jpg" id = "imageBox"></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
JS
function searchtrack(){
var input = document.getElementById("userinput").value;
document.getElementById("trackdata").style.display = "display"; //Display trackdata
document.getElementById("notrackdata").style.display = "none"; //Hide notrackdata
}
CSS
.trackdata{
background-color: #DCDCDC;
margin:auto;
margin-top:1%;
text-align: center;
}
If I use display ="block"; and display = "inline-block I lose the CSS stylings. How can I make sure to keep the stylings while displaying the table as block or inline-block?
document.getElementById("trackdata").style.display = "block";instead of doing this stuffdocument.getElementById("trackdata").style.display = "display";