RSS
people

Show hide table row problem

If you try to show/hide an element in javascript, you simply use the code :

//To show the object with id toHide
   document.getElementById('toHide').style.display = 'block';
//To hide the object with id toHide
   document.getElementById('toHide').style.display = 'none';

But, when you try to apply the same logic to show and hide table rows, you get distorted table in firefox, chrome & safari. Although it works well in IE.

This problem is irritating and the fix is very simple. Instead of display=’block’ use display=”

document.getElementById("toHide").style.display = ''; //To Show it Back 
document.getElementById("toHide").style.display = 'none'; //To Hide it again
1 Comment | Tags: , , , , , , , , ,