I have the following Code:
<table>
<tr class=odd><td>Entry 1</td></tr>
<tr class=even clickable onclick=showHide('sub2')><td>> Entry 2</td></tr>
<tr class=even id=sub2>
<td><ul><li>Information 1</li><li>Information 2</li></ul></td>
</tr>
<tr class=odd><td>Entry 3</td></tr>
<tr class=even><td>Entry 4</td></tr>
</table>
and the following js:
function showHide(id) {
var el = document.getElementById(id);
if( el && el.style.display == 'none')
el.style.display = 'block';
else
el.style.display = 'none';
}
with this css:
tr.odd{
background-color: #dedede;
}
tr.even{
background-color: #7ea9ff;
}
tr.clickable{
cursor: pointer;
}
tr.clickable:hover{
color: white;
}
tr[id^=sub]{
display: none;
}
Could someone please tell me, why it doesn't work? I'm trying to show / hide onclick the row with the id=sub2