0
I’m setting up a responsive table with vertical alignment where css inserts via:content: attr(data-title);
the value of the thead field(th).
HTML desired
<table class="table table-bordered table-striped mb0">
<thead>
<tr>
<th>Codigo </th>
<th>Nome </th>
<th>Telefone </th>
</tr>
</thead>
<tbody>
<tr>
<td data-title="Código">113244</td>
<td data-title="Nome">Fulano da Silva</td>
<td data-title="Telefone">+55 11 3213213</td>
</tr>
</tbody>
</table>
HTML religion
<table class="table table-bordered table-striped mb0">
<thead>
<tr>
<th>Codigo </th>
<th>Nome </th>
<th>Telefone </th>
</tr>
</thead>
<tbody>
<tr>
<td data-title="Código">113244</td>
<td data-title="Código">Fulano da Silva</td>
<td data-title="Código">+55 11 3213213</td>
</tr>
</tbody>
</table>
JS
$('th').each(function() {
$('td').attr('data-title', $(this).text());
});
CSS
#no-more-tables td::before {
content: attr(data-title);
}
It would be possible to use a dynamic mode, where each data-title be referring to your thead th?
Hi Kim. Try to mark the answers to your questions. If you don’t know how it works, see the page Tour.
– Sam