I am new to web programming. So I have modified a code that I found online and ended up with this : jsfiddle.net/y4Mdy/673 witch works fine, all the header rows in the table are shown and the others are hidden, and then can be revealed by clicking the headers.
But When I am trying to assemble the html, CSS and JavaScript together (following the instruction found here) it does not seem to work. When I click on the headers nothing happens, the other rows are not revealed. Here is the content of my html file :
<html>
<head>
<script type="text/javascript">
$('.header').click(function () {
$(this).find('span').text(function (_, value) {
return value == '-' ? '+' : '-'
});
$(this).nextUntil('tr.header').slideToggle(100, function () {});
});
</script>.
<style>
table, tr, td, th {
border-collapse:collapse;
}
tr {
display: none;
}
table {
margin-left:auto;
margin-right:auto;
text-align:center;
}
tr.header {
cursor:pointer;
display: table-row;
}
</style>.
</head>
<body>
<table>
<tr class="header">
<th><span>+</span> Header</th>
</tr>
<tr>
<td>data</td>
<td>data</td>
</tr>
<tr>
<td>data</td>
<td>data</td>
</tr>
<tr class="header">
<th><span>+</span> Header</th>
</tr>
<tr>
<td>date</td>
<td>data</td>
</tr>
<tr>
<td>data</td>
<td>data</td>
</tr>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table>
</body>
</html>