Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  102] [ 7]  / answers: 1 / hits: 21870  / 13 Years ago, mon, february 6, 2012, 12:00:00

I have some code that shows a tables row when something is clicked. So, the row has it's style attribute disabled, see below:



HTML



<tr id='Asset' class='rrtr' style='display:none;'>


The user clicks and fires the Javascript, which works fine:



Javascript



document.getElementById(Asset).style.display = 'block';


However, the style of the row isn't in line with rest even though it's class attributes are set to 'rrtr' like the rest.



If I turn off 'display:none;' on the row and run it showing, the format is fine.



Any ideas?


More From » html-table

 Answers
16

For best compatibility, set



document.getElementById(Asset).style.display = '';


Internet Explorer 7 and lower do not support table-row as a value for display. Alternatively– and, arguably, a better idea is to – set a class for the row and remove/change it using JS:



<tr id='Asset' class='rrtr rrtr-hidden'>
<!-- .rrtr-hidden { display: none; } -->




// Remove class `.rrtr-hidden`
document.getElementById(Asset).className = 'rrtr';

[#87622] Saturday, February 4, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
havenbilliec

Total Points: 324
Total Questions: 106
Total Answers: 94

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;