I have a schedule page,我想根据时间段重新格式化。例如:比阿特丽斯在周一9点和10点。我想把这两个时间段组合起来,在浏览器中看起来像一个区块。我从文件中读取时间表,并将其打印到屏幕上。我想用jQ把它们结合起来。我的想法是:将每个div与下一个div进行比较,如果它们是相同的;cnt向上,我隐藏重复的条目,并使第一个条目的高度覆盖所有重复的条目。
到目前为止,我得到的是:
var cnt = 1;
$('.sched-col').each(function(){ //for each column
$(this).find('.worker').each(function(){ //look for each time block
if ($(this).html() == $(this).next().html()) { //if block is the same as the next
cnt++; //increase the count
$(this).next().css('display', 'none'); //hide the following block
$(this).css('height', boxH * cnt); //adjust height to cover following block
}
});
cnt = 1; //reset counter for new column
});
我知道逻辑实际上并不在那里。我需要找到一个名字,计算下面有相同名字的区块的数量,隐藏这些区块并相应地调整高度,然后重新设置每个新名称的计数。我只是需要一些帮助才能把它放入代码中。
https://stackoverflow.com/questions/50650223
复制相似问题