Is there a way to toggle the display of data rows in a table by clicking on a break row? The desired functionality is to show hidden rows and hide shown rows. Here's an example of the table:
I came across a helpful discussion on StackOverflow that provides exactly what I need, but I'm having trouble implementing it successfully. Any assistance would be greatly appreciated.
Below is my dynamically generated HTML page with the table structure:
$(document).ready(function() {
$("#gobutton").click(function() {
var userText = $("#inputText").val();
var data = processRawData(userText);
// additional processing steps
// creating table string with dynamic content
var tableString = '';
// appending final table output
$("#gradesTable").append(tableString);
});
$('.first-level').click(function() {
$(this).nextUntil('.first-level').toggle("slow");
});
});
// Additional JavaScript functions
// CSS code snippet for table styling
table {
border-collapse: collapse;
width: 100%;
}
th,
td {
padding: 8px;
text-align: center;
border-bottom: 1px solid #ddd;
}
tr:hover {
background-color: #f5f5f5;
}
.datarow {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="Header">
<h1>Learning Query</h1>
</div>
<div class="container">
<textarea type="text" class="form-control" rows="11" id="inputText" placeholder="Paste Here"></textarea>
<button type="button" id="gobutton">Go</button>
<table id='gradesTable'>
<thead>
<tr class="tableheader">
<th>Time Period</th>
<th>Units Taken</th>
<th>Credits Earned</th>
<th>GPA</th>
</tr>
</thead>
<tbody>
<!-- Table rows will be dynamically added here -->
</table>
</div>