Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Voici le code associé à mon tableau :
- <table class="table table-condensed tablesorter" id="results">
- <thead class="floating-header">
- <tr>
- <th>Nom</th>
- <th>Âge</th>
- <th>Pays</th>
- <th>...</th>
- <th>...</th>
- <th>...</th>
- <th>...</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>Carmen</td>
- <td>33 ans</td>
- <td>Espagne</td>
- <td>...</td>
- <td>...</td>
- <td>...</td>
- <td>...</td>
- </tr>
- <tr>
- <td>Michelle</td>
- <td>26 ans</td>
- <td>États-Unis</td>
- <td>...</td>
- <td>...</td>
- <td>...</td>
- <td>...</td>
- </tr>
- </tbody>
- </table>
- (qui contient en réalité une centaine de ligne)
- Et voici le code Javascript que j'ai utilisé pour fixer l'entête au top lors d'un scroll > 90px :
- $('#results thead').affix({
- offset: {
- top: 90
- }
- });
- // Changement de la couleur de fond de l'entête du tableau au scroll
- $(window).scroll(function(){
- if ($(this).scrollTop() > 90){
- $('#results thead').css('background-color','#EFEFEF');
- }
- });
- $(".floating-header th").each(function() {
- $(this).width($(this).width());
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment