Skip to content

Instantly share code, notes, and snippets.

@ankedsgn
Last active December 22, 2020 08:47
Show Gist options
  • Save ankedsgn/df32c883d2dff617c6aba051401ef8e5 to your computer and use it in GitHub Desktop.
Save ankedsgn/df32c883d2dff617c6aba051401ef8e5 to your computer and use it in GitHub Desktop.
Responsive table - Adds th's to each td in mobile version
if(window.innerWidth < 768) {
$('table.content-table').each(function( index ) {
var ths = $( this ).find('th');
var trs = $( this ).find('tr');
trs.each(function(){
$(this).find('td').each(function(i){
var text="<span>"+ths.eq(i).html()+"</span>";
$(this).prepend(text);
})
});
});
}
<table class="content-table">
<tr>
<th>Type snelheid</th>
<th>Uitleg</th>
<th>Meten</th>
</tr>
<tr>
<td>Geadverteerde download- en uploadsnelheid</td>
<td>De maximale tot internetsnelheid zoals gecommuniceerd</td>
<td>Niet van toepassing</td>
</tr>
<tr>
<td>Maximale download- en uploadsnelheid</td>
<td>De maximale internetsnelheid op basis van de technische mogelijkheden </td>
<td>90% van de maximale snelheid moet tenminste in1 van de 10 uitgevoerde metingen gemeten worden</td>
</tr>
<tr>
<td>Geadverteerde download- en uploadsnelheid</td>
<td>De maximale tot internetsnelheid zoals gecommuniceerd</td>
<td>Niet van toepassing</td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment