$(function(){ $(document).ready(function() { // intégration du tableau correspondant au lien cliqué $("a.load").click(function() { $("#myTable").load(this.href, function() { supprimerTHEAD(); creerTHEAD(); ajusterTHEAD(); }); return false; }); creationLiensMenu(); }); }); window.onresize = function() { reglerLargeurTHEAD(); reglerHauteurTHEAD(); } function supprimerTHEAD(){ if ($("#fixTable thead").length > 0){ // s'il existe un fixed header $("#fixTable thead").remove(); } } function creerTHEAD(){ var fixed_table = $("#fixTable"); var fixed_thead = $("#myTable thead").clone(); // correspond au clone du thead de myTable fixed_table.append(fixed_thead); } function ajusterTHEAD(){ reglerLargeurTHEAD(); reglerHauteurTHEAD(); } function reglerLargeurTHEAD(){ var tabInnerWidth=[]; var th_table = $("#myTable>thead").find('th'); $("#myTable>thead").find('th').each(function(index){ // recup la largeur de chaque th de myTable tabInnerWidth[index] = $(this).innerWidth(); }); $("#fixTable>thead").find('th').each(function(index){ // modif de la largeur de chaque th de fixTable $(this).css({width: tabInnerWidth[index]}); }); } function reglerHauteurTHEAD(){ var fixed_thead = $("#fixTable thead"); var height_thead=$("#myTable thead").height(); fixed_thead.height(height_thead+1); }