tr display none crashes ie9

前端 未结 4 1198
无人及你
无人及你 2020-12-17 23:47

This code crashes ie9 as i am having this problem in my code .. any work around will be appreciated .. This is not a problem with the previous versions of ie .. Thanks ..

4条回答
  •  执笔经年
    2020-12-18 00:31

    I have the same problem, and have found a solution. First of all I should say that the problem is actual for any row in table with style borderCollapse equal to collapse (no matter if it is declared inline or in head) in IE9.

    My solution:

    function hideRow(tableNode, rowNode, hide){
        if(hide){
            if(window.navigator.userAgent.search('MSIE 9.0') != -1){
                var initValue = tableNode.style.borderCollapse;
                tableNode.style.borderCollapse = 'separate';
                rowNode.style.display = 'none';
                tableNode.style.borderCollapse = initValue;
            }else{
                rowNode.style.display = 'none';
            }
        }else{
            rowNode.style.display = '';
        }
    }
    

    Or even shorten:

    function hideRow(tableNode, rowNode, hide){
        var initValue = tableNode.style.borderCollapse;
        tableNode.style.borderCollapse = 'separate';
        rowNode.style.display = hide ? 'none' : '';
        tableNode.style.borderCollapse = initValue;
    }
    

提交回复
热议问题