JSFiddle - React, Tailwind, and code Playground
HTML
<div id="header_container">
<div id="header"> <a href="http://site.com/" target="_blank"><img src="http://placehold.it/300x80"/></a>
<select class="class-selector">
<option value="">-select class-</option>
</select>
<div id="header1">Semi-Transparent Image <a href="#TOP"><font color="#EFEFEF">Up to Top</font></a> | <a href="#KEY"><font color="#EFEFEF">Down to Key</font></a> | <a class="def" href="javascript: void(0);"><font color="#EFEFEF">Scroll Left</font></a> | <a class="abc" href="javascript: void(0);"><font color="#EFEFEF">Scroll Right</font></a>
</div>
</div>
</div>
<a id="TOP"></a>
<div id="container">
<table id="gradient-style" cellpadding="0" cellspacing="0" border="0">
<tbody>
<thead>
<tr>
<th scope="col"><a id="CLASS1"></a>title</th>
<th scope="col">title</th>
<th scope="col">title</th>
<th scope="col">Class</th>
<th scope="col">Class Number</th>
<th scope="col">title text</th>
<th scope="col">title text</th>
<th scope="col">title text</th>
<th scope="col">title text
<br/>data text</th>
<th scope="col">title text</th>
<th scope="col">title text
<br/>data text</th>
<th scope="col">title text</th>
<th scope="col">title text</th>
<th scope="col">text</th>
<th scope="col">title text</th>
<th scope="col">title text</th>
<th scope="col">title text
<br/>data text</th>
<th scope="col">title text
<br/>data text</th>
<th scope="col">title text
<br/>data text</th>
...
CSS
/*NEW ADDITIONS TO CSS*/
td, th {
white-space:nowrap;
}
#container tbody, #container thead {
display:none;
}
#container tbody.current {
display:table-row-group;
}
#container thead.current {
display:table-header-group;
}
#header .class-selector {
left: 0;
position: absolute;
}
/*OLD CSS*/
body {
line-height: 1.6em;
background-color: #0aad9e;
}
#gradient-style {
font-family:"Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 0px;
width: 100%;
text-align: center;
border-collapse: collapse;
}
#gradient-style th {
font-size: 13px;
font-weight: normal;
padding: 2px;
background: #0aad9e url('table-images/gradhead.png') repeat-x;
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
color: #ffffff;
}
#gradient-style th.alt {
font-family:"Times New Roman", Serif;
text-align: left;
padding: 10px;
font-size: 26px;
}
#gradient-style td {
padding: 2px;
border-bottom: 1px solid #fff;
border-left: 1px solid #fff;
border-right: 1px solid #fff;
color: #00000;
border-top: 1px solid #fff;
background: #ad750a url('table-images/gradback.png') repeat-x;
}
#gradient-style tr.ft3 td {
color: #00000;
background: #ad0a7d url('table-images/gradoverallstudent.png') repeat-x;
font-weight: bold;
}
#gradient-style tr.f1 td {
color: #00000;
background: #ad0a7d url('table-images/gradbeststudent.png') repeat-x;
}
#gradient-style tr.f2 td {
color: #00000;
background: #7f0aad url('table-images/gradmostattentedstudent.png') repeat-x;
}
#gradient-style tr.f3 td {
color: #00000;
background: #71ad0a url('table-images/gradleastlatestudtent.png') repeat-x;
}
#gradient-style tfoot tr td {
background: #6FA275;
font-size: 12px;
color: #000;
padding: 10;
text-align: left;
}
#gradient-style tbody tr:hover td, #gradient-style tbody tr.selected td {
background: #d0dafd...
JavaScript
$(document).ready(function () {
var jsonRequest,
jsonTimeout,
classSelector = $('.class-selector');
// gather CLASS info
classSelector.on('change', function () {
if (jsonTimeout) clearTimeout(jsonTimeout);
if (jsonRequest) jsonRequest.abort();
var id = this.value;
$('#container').find('thead, tbody').removeClass('current');
if (id !== '') {
//scrollToAnchor(id);
var group = $('#' + id).closest('thead');
group.add(group.next('tbody'))
.addClass('current');
}
// since we changed the current class, initiate a checkdata() so that we can update as soon as possible..
checkData();
}).trigger('change');
$('a[id^="CLASS"]').each(function () {
var id = this.id,
option = $('<option>', {
value: this.id,
text: this.id
});
classSelector.append(option);
});
function handleData(data) {
alert('handling data');
//loop over data and edit the DOM
var classBody = $('#container').find('tbody.current');
$.each(data, function (index, item) {
// variable item refers to the current CLASS of the iteration
// assuming that the JSON is an array of CLASS groups describing the rows..
// populate classBody with the JSON data
});
jsonTimeout = setTimeout(checkData, 10000); // change the 10000 to whatever you want.. i set it to 10 seconds to see the repeating..
}
function checkData() {
var currentId = classSelector.val();
if (currentId !== ''){
// Start AJAX request
alert('starting ajax request for ' + currentId);
// change /echo/json/ with the url to your json
// delay should be removed, it just for jsfiddle..
jsonRequest =...