Мне пришлось прибегнуть к этой уловке, чтобы установить высоту div01-05, отличную от div11-15
var maxheight = divheight;
var dayofweek = ;
var heightoffset = (2 - dayofweek) * 40;
var days = jQuery('div.day01, div.day02, div.day03, div.day04, div.day05');
for (i=0; i maxheight) {
maxheight = hh;
};
jQuery(days).height(divheight+heightoffset);
};
var days = jQuery('div.day11, div.day12, div.day13, div.day14, div.day15');
for (i=0; i maxheight) {
maxheight = hh;
};
jQuery(days).height(divheight-heightoffset);
};
//Back to full array for further processing
var days = jQuery('div.day01, div.day02, div.day03, div.day04, div.day05, div.day11, div.day12, div.day13, div.day14, div.day15');
Кто-нибудь избавит меня от страданий и покажет, как просто перебирать все элементы div и задавать условную высоту.
Один предостережение: PHP поддерживает div.day01 -04, а div.day01 -04 может не существовать в зависимости от дня недели. div.day05 всегда существует, как и divs day11-15.
С уважением
Саймон
Окончательный результат кода (исправлено использование идентификаторов вместо классов
jQuery('div[id^="day"]').each(function() {
var hh = jQuery(this).prop("scrollHeight");
if (hh > maxheight) {maxheight = hh;};
var cn = jQuery(this).attr('id').split(" ")[0]; // Since PHP is creating these classes, we can safely assume "day" will always be the first.
var num = parseInt(cn.slice(-2),10); // extract the last two characters and convert to an integer
if (num >=1 && num =10 && num
Мне пришлось прибегнуть к этой уловке, чтобы установить высоту div01-05, отличную от div11-15 :( var maxheight = divheight; var dayofweek = ; var heightoffset = (2 - dayofweek) * 40;
var days = jQuery('div.day01, div.day02, div.day03, div.day04, div.day05'); for (i=0; i maxheight) { maxheight = hh; }; jQuery(days[i]).height(divheight+heightoffset); };
var days = jQuery('div.day11, div.day12, div.day13, div.day14, div.day15'); for (i=0; i maxheight) { maxheight = hh; }; jQuery(days[i]).height(divheight-heightoffset); };
//Back to full array for further processing var days = jQuery('div.day01, div.day02, div.day03, div.day04, div.day05, div.day11, div.day12, div.day13, div.day14, div.day15');
Кто-нибудь избавит меня от страданий и покажет, как просто перебирать все элементы div и задавать условную высоту. Один предостережение: PHP поддерживает div.day01 -04, а div.day01 -04 может не существовать в зависимости от дня недели. div.day05 всегда существует, как и divs day11-15. С уважением Саймон Окончательный результат кода (исправлено использование идентификаторов вместо классов :) jQuery('div[id^="day"]').each(function() { var hh = jQuery(this).prop("scrollHeight"); if (hh > maxheight) {maxheight = hh;}; var cn = jQuery(this).attr('id').split(" ")[0]; // Since PHP is creating these classes, we can safely assume "day" will always be the first. var num = parseInt(cn.slice(-2),10); // extract the last two characters and convert to an integer if (num >=1 && num =10 && num