$("td[rowspan]").each(function (index, item) {
let colors = ['#ffeab3', '#c5aecb', '#E97F9B', '#A3BB9E', '#E87E73', '#E2EDBA', '#97CFA2', '#F8A98B', '#DCEBBC','#BDC3D5','#DDD0D0','#E0C2C8','#9B737C','#949DB6']
let colorIndex = Math.floor(Math.random() * colors.length)
let length = $(item).attr('rowspan')
$(item).parent().css('background', colors[colorIndex])
let color = $(item).parent().css('background')
$(item).parent().nextAll().each(function (i, n) {
if (i < length - 1) {
$(n).css('background', color)
}
})
})
js table合并单元格后为同行单元格赋色
最新推荐文章于 2024-05-24 17:50:52 发布