How to toggle showing and hiding a table row with JavaScript cross browsers

This is how you can toggle showing and hiding a table row with JavaScript cross browsers. This works fine with Internet Explorer 8, Firefox 3 and Opera 10.

  function klToggle (rowid) {

    var togrow = document.getElementById(rowid);

    if(togrow.style.visibility == "collapse") {
      togrow.style.visibility = "visible";
      togrow.style.display = "table-row"; //if not a table row ' = "block"; '
     

    }else{
      togrow.style.visibility = "collapse";
      togrow.style.display = "none";
    }

  }
Knowledge keywords: