Created
February 8, 2013 14:31
-
-
Save egorvinogradov/4739343 to your computer and use it in GitHub Desktop.
Делает одинаковой ширину соответствующих колонок у таблиц, идущих друг под другом.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_max_width_array(tables){ | |
var max_width_arr = []; | |
tables.each(function(i, table){ | |
$(table).find('tr').first().find('th, td').each(function(i, td){ | |
var width = $(td).width(); | |
if ( !max_width_arr[i] || max_width_arr[i] < width ) { | |
max_width_arr[i] = width; | |
}); | |
}); | |
return max_width_arr; | |
}; | |
var all_tables = $('table'); | |
var width_arr = get_max_width_array(all_tables); | |
all_tables.each(function(i, table){ | |
$(table).find('tr').first().find('th, td').each(function(i, td){ | |
$(td).width(width_arr[i]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment