1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| function slidetable(idslide) {
var tabs = $(idslide);
// ajout des div
tabs.find('th, td').each(function() {
$(this).html('<div>' + $(this).html() + '</div>');
});
// masquer les cellules au départ
tabs.find('th:not(:first-child), tr td:not(:first-child), th:not(:first-child) > div, tr td:not(:first-child) > div').css({'display':'none'});
// afficher/masquer au click sur les entêtes
tabs.on('click', 'th', function() {
var thistab = $(this).closest('table');
if (thistab.find('th:not(:first-child) div, tr td:not(:first-child) div').css('display') == 'block') {
thistab.find('th:not(:first-child) div, tr td:not(:first-child) div').hide(0);
thistab.find('td:not(:first-child), th:not(:first-child)').animate({
width: 'toggle'
}, 500, function() {
// Animation complete.
// (rien ici)
});
} else {
thistab.find('td:not(:first-child), th:not(:first-child)').animate({
width: 'toggle'
}, 500, function() {
// Animation complete.
thistab.find('th:not(:first-child) div, tr td:not(:first-child) div').fadeIn();
});
}
});
}
$(window).on('load', function() {
slidetable(".tabslide"); // activation du slide
}); |
Partager