jeudi 13 août 2015

Send While Loop To Next Row If No Change

Because we can't set table-cell's max-height so I am using this loop to limit row height (equal to cell), by increasing the table width until all rows height < max-height I set.

var i = 0,
    row, table = document.getElementsByTagName('table')[0],
    j = table.offsetWidth;
while (row = table.rows[i++]) {
    while (row.offsetHeight > 200 && j < 3000) {
        j += 250;
        table.style.width = j + 'px';
    }
}

But there is a problem in this script, if for some reason a specific row height can't be less than 400px, which is greater than max-height I set for rows in script, the table becomes unnecessary 3000px wide because of the condition in loop.

Is there any way to send loop to next row if a row height is same before and after table width increment by loop. I tried web searching but nothing found to handle this, if anyone here knows about this please help me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire