How can I edit the following script so that I can get the td appear under the corresponding th, not every td under the first th? Want to hide/show contents of tr based on th clicked
function toggleColumn(n) {
var currentClass = document.getElementById("mytable").className;
if (currentClass.indexOf("show" + n) != -1) {
document.getElementById("mytable").className = currentClass.replace("show" + n, "");
} else {
document.getElementById("mytable").className += " " + "show" + n;
}
}